Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#24477 closed defect (bug) (invalid)

_wp_preview_meta_filter should check if $post is empty

Reported by: itthinx's profile itthinx Owned by:
Milestone: Priority: normal
Severity: minor Version: 3.6
Component: Revisions Keywords:
Focuses: Cc:


The filter misses to check for empty( $post ) which can lead to problems when get_post_meta() is called during preview.

Here is an example where this happens (note that in this example the Groups plugin is involved, but the issue is not dependent on the plugin) :

PHP Notice:  Trying to get property of non-object in /var/www/groups-newsletters/wp-includes/revision.php on line 543
[01-Jun-2013 13:27:37] PHP Stack trace:
[01-Jun-2013 13:27:37] PHP   1. {main}() /var/www/groups-newsletters/index.php:0
[01-Jun-2013 13:27:37] PHP   2. require() /var/www/groups-newsletters/index.php:17
[01-Jun-2013 13:27:37] PHP   3. wp() /var/www/groups-newsletters/wp-blog-header.php:14
[01-Jun-2013 13:27:37] PHP   4. WP->main() /var/www/groups-newsletters/wp-includes/functions.php:779
[01-Jun-2013 13:27:37] PHP   5. WP->query_posts() /var/www/groups-newsletters/wp-includes/class-wp.php:549
[01-Jun-2013 13:27:37] PHP   6. WP_Query->query() /var/www/groups-newsletters/wp-includes/class-wp.php:485
[01-Jun-2013 13:27:37] PHP   7. WP_Query->get_posts() /var/www/groups-newsletters/wp-includes/query.php:2985
[01-Jun-2013 13:27:37] PHP   8. apply_filters_ref_array() /var/www/groups-newsletters/wp-includes/query.php:2785
[01-Jun-2013 13:27:37] PHP   9. call_user_func_array() /var/www/groups-newsletters/wp-includes/plugin.php:230
[01-Jun-2013 13:27:37] PHP  10. Groups_Post_Access::the_posts() /var/www/groups-newsletters/wp-includes/plugin.php:0
[01-Jun-2013 13:27:37] PHP  11. Groups_Post_Access::user_can_read_post() /var/www/groups-newsletters/wp-content/plugins/groups/lib/access/class-groups-post-access.php:192
[01-Jun-2013 13:27:37] PHP  12. Groups_Post_Access::get_read_post_capabilities() /var/www/groups-newsletters/wp-content/plugins/groups/lib/access/class-groups-post-access.php:360
[01-Jun-2013 13:27:37] PHP  13. get_post_meta() /var/www/groups-newsletters/wp-content/plugins/groups/lib/access/class-groups-post-access.php:341
[01-Jun-2013 13:27:37] PHP  14. get_metadata() /var/www/groups-newsletters/wp-includes/post.php:1715
[01-Jun-2013 13:27:37] PHP  15. apply_filters() /var/www/groups-newsletters/wp-includes/meta.php:274
[01-Jun-2013 13:27:37] PHP  16. call_user_func_array() /var/www/groups-newsletters/wp-includes/plugin.php:173
[01-Jun-2013 13:27:37] PHP  17. _wp_preview_meta_filter() /var/www/groups-newsletters/wp-includes/plugin.php:0

Attachments (1)

revision.php.patch (648 bytes) - added by itthinx 11 years ago.
This patch adds the empty( $post ) check to the filter.

Download all attachments as: .zip

Change History (3)

11 years ago

This patch adds the empty( $post ) check to the filter.

#1 @ocean90
11 years ago

  • Keywords close added

Seems like the lines will be removed, see #24455.

#2 @ocean90
11 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Removed in [24397].

Note: See TracTickets for help on using tickets.