Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#24258 closed defect (bug) (duplicate)

PHP notices throws when the attachment parent not exists

Reported by: alex-ye Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5.1
Component: Media Keywords: has-patch
Focuses: Cc:


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 ).


Attachments (3)

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

Download all attachments as: .zip

Change History (10)

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

  • Version set to 3.5.1

#2 in reply to: ↑ 1 @adamsilverstein
8 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
8 years ago

  • Cc adamsilverstein@… added

#4 @SergeyBiryukov
8 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 8 years ago by SergeyBiryukov (previous) (diff)

#5 @SergeyBiryukov
8 years ago

  • Resolution set to duplicate

#6 @alex-ye
8 years ago

Thanks for your reply @adamsilverstein you really helps me :)

@SergeyBiryukov mmm, can apply the patch:

Insted of

I think the @adamsilverstein patch is better.

#7 @SergeyBiryukov
8 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 8 years ago by SergeyBiryukov (previous) (diff)
Note: See TracTickets for help on using tickets.