#22312 closed defect (bug) (fixed)
Notice for media attached to "retired" custom post type
Reported by: | trepmal | Owned by: | 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
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)
Change History (12)
#2
@
12 years ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to 3.5
- Severity changed from normal to minor
#3
@
12 years ago
- Component changed from General to Post Types
- Milestone changed from 3.5 to Future Release
#5
follow-up:
↓ 9
@
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
@
12 years ago
- Component changed from Post Types to Media
- Milestone changed from Future Release to 3.6
Related: #23154
#9
in reply to:
↑ 5
@
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).
Related: #16956