[wp-trac] [WordPress Trac] #25324: Break in capabilities.php if $post_type is null
WordPress Trac
noreply at wordpress.org
Sun Sep 15 15:27:23 UTC 2013
#25324: Break in capabilities.php if $post_type is null
--------------------------+-----------------------------
Reporter: nofearinc | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.6.1
Severity: normal | Keywords: has-patch
--------------------------+-----------------------------
There is an edge case in capabilities.php where $post_type could be null
while verifying capabilities as there is some database data assigned to a
post_type that is no longer registered.
Steps to reproduce on a clean install:
1) Register a post type
2) Create an entry from this post type
3) Publish a comment for the post type
4) Remove the post type registering function (i.e. post type no longer
exists)
5) Go to the Edit Comments listing in Admin panel
This is the sort of notices I get for comments related to the post type
(all normal comments in registered post types are fine):
https://gist.github.com/mpeshev/ccb317a7c2ceb5bbd385
Adding a sample patch addressing the issue - the global `$wp_post_types`
has no information about the old post type, therefore
`get_post_type_object` returns null. There might be a smarter way to
address that - such as just returning the post type name, but I think it's
safer.
Note: There are several other calls in the same file to the same function,
so it probably has to be addressed there as well, but I was unable to
trigger another related error.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/25324>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list