Make WordPress Core

Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#19706 closed defect (bug) (invalid)

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

Reported by: markjaquith's profile markjaquith Owned by:
Milestone: Priority: low
Severity: normal Version: 3.3
Component: Warnings/Notices Keywords:
Focuses: Cc:


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.


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

Just discard empty post_status rows.

Change History (5)

#1 @solarissmoke
12 years ago

Isn't the real bug that somehow you managed to get a post with an empty post_status? According to the phpdoc for get_post_statuses(), posts have a limited set of valid status values (and empty isn't one of them).

#2 @mp3j3rk
12 years ago

  • Cc mp3j3rk added

This should be aimed at the code that saves a post to the DB then, and why it would have placed an empty value in wp_posts.post_status without having thrown an error.

I need a pet project, I think I'll give this one a look-see.

@markjaquith What steps did you take to produce the notice, and can you confirm any out of the ordinary circumstances when you published that post?

Last edited 12 years ago by mp3j3rk (previous) (diff)

#3 @nacin
12 years ago

  • Keywords close added
  • Milestone changed from 3.4 to Awaiting Review

wp_insert_post() sets the post_status to 'draft' if it is empty. I don't think this was caused by core and is probably not something we should "fix" as it points to a developer issue. (Additionally, I doubt this is the only area in core that breaks due to this, whether or not it throws a notice.)

#4 @c3mdigital
11 years ago

  • Resolution set to invalid
  • Status changed from new to closed

No discussion in 16 months. Closing based on comments above.

#5 @SergeyBiryukov
11 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.