Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#24258 closed defect (bug) (duplicate)

PHP notices throws when the attachment parent not exists

Reported by: alex-ye's profile alex-ye 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)

link-template.patch (2.4 KB) - added by alex-ye 11 years ago.
class-wp-media-list-table.patch (1.6 KB) - added by alex-ye 11 years ago.
24258.diff (1.9 KB) - added by adamsilverstein 11 years ago.

Download all attachments as: .zip

Change History (10)

#1 follow-up: @alex-ye
11 years ago

  • Version set to 3.5.1

#2 in reply to: ↑ 1 @adamsilverstein
11 years ago

  • Keywords dev-feedback added

Replying to alex-ye:

thank you for contributing the bug report _and_ a patch! bravo!

a few notes:

  • its best to generate your patches from wp root, this makes applying easier
  • you can combine all your file updates into a single patch (same reason)
  • watch out for spaces vs. tabs, you might want to turn these on visually in your editor; your patch files had many lines indented with spaces - check the php coding standards

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)

#3 @adamsilverstein
11 years ago

  • Cc adamsilverstein@… added

#4 @SergeyBiryukov
11 years ago

  • Keywords dev-feedback removed
  • Milestone Awaiting Review deleted
  • Status changed from new to closed

Thanks for the contribution. This is, however, a duplicate of #22312 and #23154.

Last edited 11 years ago by SergeyBiryukov (previous) (diff)

#5 @SergeyBiryukov
11 years ago

  • Resolution set to duplicate

#6 @alex-ye
11 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 @SergeyBiryukov
11 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.

Last edited 11 years ago by SergeyBiryukov (previous) (diff)
Note: See TracTickets for help on using tickets.