Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#26451 closed defect (bug) (duplicate)

PHP notices when removing a custom post type which contains posts with attachments

Reported by: chouby's profile Chouby Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.7
Component: Media Keywords: has-patch 3.9-early
Focuses: Cc:


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)

26451.patch (744 bytes) - added by Chouby 11 years ago.
26451.2.patch (875 bytes) - added by SergeyBiryukov 11 years ago.
26451.diff (886 bytes) - added by wonderboymusic 10 years ago.

Download all attachments as: .zip

Change History (9)

#1 @Chouby
11 years ago

  • Keywords has-patch added

The patch proposed does the correction in class-wp-media-list-table.php

11 years ago

#2 @helen
11 years ago

Related: #22312

#3 @SergeyBiryukov
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.

#4 @wonderboymusic
10 years ago

  • Milestone changed from Future Release to 4.1

Yes - this is better and Attach'ing works when the link is clicked.

#5 @wonderboymusic
10 years ago

We need to also account for this in Media Grid

#6 @wonderboymusic
10 years ago

  • Milestone 4.1 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #27446.

See [29320]

Note: See TracTickets for help on using tickets.