[wp-trac] [WordPress Trac] #19706: NOTICE: wp-admin/includes/post.php:834 - Illegal member variable name

WordPress Trac wp-trac at lists.automattic.com
Sun Jan 1 00:30:44 UTC 2012


#19706: NOTICE: wp-admin/includes/post.php:834 - Illegal member variable name
------------------------------+-----------------
 Reporter:  markjaquith       |      Owner:
     Type:  defect (bug)      |     Status:  new
 Priority:  low               |  Milestone:  3.4
Component:  Warnings/Notices  |    Version:  3.3
 Severity:  normal            |   Keywords:
------------------------------+-----------------
 Received this notice:

 {{{NOTICE: wp-admin/includes/post.php:834 - Illegal member variable
 name}}}

 Traced it to this in {{{wp_count_posts()}}}:

 {{{
         $count = $wpdb->get_results( $wpdb->prepare( $query, $type ),
 ARRAY_A );

         $stats = array();
         foreach ( get_post_stati() as $state )
                 $stats[$state] = 0;

         foreach ( (array) $count as $row )
                 $stats[$row['post_status']] = $row['num_posts'];

         $stats = (object) $stats;
 }}}

 Apparently I have a post with a post status of a blank string. So that
 gets set to an array key, and then is cast to an object. WP doesn't like
 that.

 Proposed:

 {{{
         foreach ( (array) $count as $row ) {
                 if ( !empty( $row['post_status'] ) )
                         $stats[$row['post_status']] = $row['num_posts'];
         }
 }}}

 Just discard empty post_status rows.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19706>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list