#24258 closed defect (bug) (duplicate)
PHP notices throws when the attachment parent not exists
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.5.1 |
Component: | Media | Keywords: | has-patch |
Focuses: | Cc: |
Description
Some functions throws PHP notices when the attachment parent not exists ( the attachment have a value for a parent post but this post removed by any reason ).
like:
get_attachment_link()
WP_Media_List_Table=>display_rows()
Attachments (3)
Change History (10)
#4
@
12 years ago
- Keywords dev-feedback removed
- Milestone Awaiting Review deleted
- Status changed from new to closed
#6
@
12 years ago
Thanks for your reply @adamsilverstein you really helps me :)
@SergeyBiryukov mmm, can apply the patch:
http://core.trac.wordpress.org/attachment/ticket/24258/24258.diff
Insted of
http://core.trac.wordpress.org/attachment/ticket/23154/23154.diff
I think the @adamsilverstein patch is better.
#7
@
12 years ago
See the combined patch in #23154.
if ( empty( $post ) )
check in get_attachment_link()
from 24258.diff probably makes sense, but it should return a string instead of null to be in line with the function's PHPDocs, and should be consistent with other get_*_link()
functions, so it's better to address that in a separate ticket.
Replying to alex-ye:
thank you for contributing the bug report _and_ a patch! bravo!
a few notes:
24258.diff refactors your patches and is generated from the root, also cleans up spaces vs. tabs issue and a little OCD space cleanup on the get_attachment_link since we were in there anyway (although you don't usually need to clean up old code that isn't to standard)