#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
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)
#5
follow-up:
↓ 9
@
14 years ago
- Cc 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.
#9
in reply to: ↑ 5
@
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).
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)

Related: #16956