Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#27446 closed defect (bug) (fixed)

PHP notice for media attached to no more registered post type

Reported by: afercia's profile afercia Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.0 Priority: normal
Severity: normal Version: 3.7
Component: Media Keywords: has-patch commit
Focuses: Cc:


This is a follow-up to #22312.

as far as I see, #22312 fixed this when users delete a post but I still can see PHP notices in one scenario.
I've just tested on 3.9-beta1-27528 and used this plugin:
Animate Slider

to reproduce:

  1. install the plugin
  2. create a new 'Slider' CPT
  3. insert an image in the body of the post, I mean don't create a real slider but just attach an image as you would do in a standard post
  4. save the post
  5. don't delete the post, deactivate the plugin instead and doing so you've just unregistered the 'Slider' CPT
  6. go in your media library
  7. next to the image you used in your 'Slider' you will see those PHP notices

I suppose that's because #22312 patch checks for the attachment parent post existence and it still does exist but it's no more a registered post type so get_post_type_object() checks that CPT in the global $wp_post_types, can't find it and returns null

Attachments (1)

27446.patch (2.3 KB) - added by SergeyBiryukov 10 years ago.

Download all attachments as: .zip

Change History (5)

#1 @SergeyBiryukov
10 years ago

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

Duplicate of #27439.

#2 @SergeyBiryukov
10 years ago

  • Keywords has-patch commit added
  • Milestone set to 4.0
  • Resolution duplicate deleted
  • Status changed from closed to reopened

I thought this was fixed in [27560], apparently not.

27446.patch fixes this for WP_Media_List_Table and synchronizes the edit_post capability check between the list table and the media grid.

#3 @SergeyBiryukov
10 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from reopened to closed

In 29320:

Avoid PHP notices in Media Library if an attachment parent post type no longer exists.

Synchronize the 'edit_post' capability check between the list table and the media grid.

fixes #27446.

#4 @wonderboymusic
10 years ago

#26451 was marked as a duplicate.

Note: See TracTickets for help on using tickets.