PHP notices when removing a custom post type which contains posts with attachments
|Reported by:||Chouby||Owned by:|
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)