Opened 11 years ago
Closed 11 years ago
#26451 closed defect (bug) (duplicate)
PHP notices when removing a custom post type which contains posts with attachments
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.7 |
Component: | Media | Keywords: | has-patch 3.9-early |
Focuses: | Cc: |
Description
To reproduce, just create a plugin which registers a certain custom post type. Create a post in this custom post type with some attachments. De-activate the plugin. Go to the media list table.
The title of the just created post is displayed without link in the column "uploaded to" and PHP notices are logged:
Trying to get property of non-object in /wp-includes/capabilities.php on 1116
Same thing for lines 1117, 1120
The problems comes from the fact that after the line 1114
$post_type = get_post_type_object( $post->post_type );
There is no check that the returned post type is valid or not.
In that particular case, I am not sure if we should test for the validity of the post type in the meta_cap function or in the calling function (line 314 in class-wp-media-list-table.php)
Attachments (3)
Change History (9)
#3
@
11 years ago
- Keywords 3.9-early added
- Milestone changed from Awaiting Review to Future Release
- Version set to 3.7
Introduced in [25140].
If the parent post type no longer exists, we should probably show the image as unattached: 26451.2.patch.
The patch proposed does the correction in class-wp-media-list-table.php