Make WordPress Core

Opened 14 years ago

Closed 13 years ago

Last modified 13 years ago

#22312 closed defect (bug) (fixed)

Notice for media attached to "retired" custom post type

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

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 14 years ago.

Download all attachments as: .zip

Change History (12)

@trepmal
14 years ago

#2 @scribu
14 years ago

  • Keywords has-patch added
  • Milestone Awaiting Review3.5
  • Severity normalminor

#3 @nacin
14 years ago

  • Component GeneralPost Types
  • Milestone 3.5Future Release

#4 @SergeyBiryukov
14 years ago

#22874 was marked as a duplicate.

#5 follow-up: @jtsternberg
14 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
14 years ago

  • Component Post TypesMedia
  • Milestone Future Release3.6

Related: #23154

#7 @sabreuse
14 years ago

  • Cc sabreuse added

#8 @SergeyBiryukov
13 years ago

#24258 was marked as a duplicate.

#9 in reply to: ↑ 5 @SergeyBiryukov
13 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
13 years ago

  • Owner set to SergeyBiryukov
  • Resolutionfixed
  • Status newclosed

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
13 years ago

#23409 was marked as a duplicate.

Note: See TracTickets for help on using tickets.