From 9c1d22a45474f633b42f0af4540eb6299a360fa7 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 29 Jul 2014 00:51:17 +0000 Subject: [PATCH] Avoid PHP notices in _count_posts_cache_key(), _update_blog_date_on_post_publish(), and _update_blog_date_on_post_delete() if post type is not registered. props jesin. fixes #28135. Built from https://develop.svn.wordpress.org/trunk@29318 git-svn-id: http://core.svn.wordpress.org/trunk@29099 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/ms-blogs.php | 12 ++++++++---- wp-includes/post.php | 2 +- wp-includes/version.php | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/wp-includes/ms-blogs.php b/wp-includes/ms-blogs.php index e2c3f208f5..29e96bbf13 100644 --- a/wp-includes/ms-blogs.php +++ b/wp-includes/ms-blogs.php @@ -874,11 +874,13 @@ function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) { */ function _update_blog_date_on_post_publish( $new_status, $old_status, $post ) { $post_type_obj = get_post_type_object( $post->post_type ); - if ( ! $post_type_obj->public ) + if ( ! $post_type_obj || ! $post_type_obj->public ) { return; + } - if ( 'publish' != $new_status && 'publish' != $old_status ) + if ( 'publish' != $new_status && 'publish' != $old_status ) { return; + } // Post was freshly published, published post was saved, or published post was unpublished. @@ -896,11 +898,13 @@ function _update_blog_date_on_post_delete( $post_id ) { $post = get_post( $post_id ); $post_type_obj = get_post_type_object( $post->post_type ); - if ( ! $post_type_obj->public ) + if ( ! $post_type_obj || ! $post_type_obj->public ) { return; + } - if ( 'publish' != $post->post_status ) + if ( 'publish' != $post->post_status ) { return; + } wpmu_update_blogs_date(); } diff --git a/wp-includes/post.php b/wp-includes/post.php index e74e2562c2..2e70023a20 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -2314,7 +2314,7 @@ function _count_posts_cache_key( $type = 'post', $perm = '' ) { $cache_key = 'posts-' . $type; if ( 'readable' == $perm && is_user_logged_in() ) { $post_type_object = get_post_type_object( $type ); - if ( ! current_user_can( $post_type_object->cap->read_private_posts ) ) { + if ( $post_type_object && ! current_user_can( $post_type_object->cap->read_private_posts ) ) { $cache_key .= '_' . $perm . '_' . get_current_user_id(); } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 3ab1e299be..3c1e0eb7c9 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.0-beta2-20140728'; +$wp_version = '4.0-beta2-20140729'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.