Make WordPress Core

Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#22312 closed defect (bug) (fixed)

Notice for media attached to "retired" custom post type

Reported by: trepmal's profile trepmal Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 3.6 Priority: normal
Severity: minor Version:
Component: Media Keywords: has-patch
Focuses: Cc:

Description

If there are attachments in the Media Library that are attached to non-existant post types, a few ugly notices will appear:

Notice: Trying to get property of non-object in /path/to/wp-includes/capabilities.php on line 1080

Notice: Trying to get property of non-object in /path/to/wp-includes/capabilities.php on line 1081

Notice: Trying to get property of non-object in /path/to/wp-includes/capabilities.php on line 1081

Notice: Trying to get property of non-object in /path/to/wp-includes/capabilities.php on line 1084

Notice: Trying to get property of non-object in /path/to/wp-includes/capabilities.php on line 1084

http://cdn.dropmark.com/17023/0b51ddeeb3862946e6c6977438a5bdcc12948d2f/2012-10-28_0836.png

I've included a patch, but I'm sure it's not the optimal solution.

Not sure if there should there be some way to indicate to the user that the attachment's post_parent is a "retired" post type

Attachments (1)

22312.diff (504 bytes) - added by trepmal 12 years ago.

Download all attachments as: .zip

Change History (12)

@trepmal
12 years ago

#2 @scribu
12 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 3.5
  • Severity changed from normal to minor

#3 @nacin
12 years ago

  • Component changed from General to Post Types
  • Milestone changed from 3.5 to Future Release

#4 @SergeyBiryukov
12 years ago

#22874 was marked as a duplicate.

#5 follow-up: @jtsternberg
12 years ago

  • Cc justin@… added

I just duplicated this issue. When the post that the attachment was attached to gets deleted, the attachment table displays a lot of php notices: http://b.ustin.co/SD2T

So this issue is not strictly related to post-types.

#6 @SergeyBiryukov
12 years ago

  • Component changed from Post Types to Media
  • Milestone changed from Future Release to 3.6

Related: #23154

#7 @sabreuse
12 years ago

  • Cc sabreuse added

#8 @SergeyBiryukov
11 years ago

#24258 was marked as a duplicate.

#9 in reply to: ↑ 5 @SergeyBiryukov
11 years ago

Replying to jtsternberg:

When the post that the attachment was attached to gets deleted, the attachment table displays a lot of php notices: http://b.ustin.co/SD2T

FWIW, wp_delete_post() updates all the post attachments when a post is deleted:
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/post.php#L2355

So the issue only happens if the post was deleted with a direct SQL query, or is missing for some other reason (like a non-existent post type).

#10 @SergeyBiryukov
11 years ago

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

In 24182:

Avoid PHP notices in Media Library if an attachment parent does not exist. props trepmal, viniciusmassuchetto, alex-ye, adamsilverstein for initial patches. fixes #22312. fixes #23154.

#11 @SergeyBiryukov
11 years ago

#23409 was marked as a duplicate.

Note: See TracTickets for help on using tickets.