Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#25324 closed defect (bug) (duplicate)

Break in capabilities.php if $post_type is null

Reported by: nofearinc's profile nofearinc Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch
Focuses: Cc:


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):

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.

Attachments (1)

25324.patch (464 bytes) - added by nofearinc 11 years ago.

Download all attachments as: .zip

Change History (2)

11 years ago

#1 @ocean90
11 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version 3.6.1 deleted

Duplicate of #16956.

Note: See TracTickets for help on using tickets.