Make WordPress Core

Opened 12 months ago

Closed 12 months ago

Last modified 8 weeks ago

#24272 closed defect (bug) (fixed)

gallery_shortcode() can throw a "trying to get property of non-object" notice if called without a post context

Reported by: kovshenin Owned by: ryan
Milestone: 3.6 Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch
Focuses: Cc:


The gallery_shortcode() function uses $post->ID without checking whether get_post() returned an actual post object. If called when a post context is not set, it throws a notice. To reproduce call this inside the Debug Bar Console:

do_shortcode( '[gallery ids="1,2,3"]' );

Attachments (1)

24272.diff (442 bytes) - added by kovshenin 12 months ago.

Download all attachments as: .zip

Change History (5)

kovshenin12 months ago

comment:1 kovshenin12 months ago

  • Keywords has-patch added

comment:2 ryan12 months ago

  • Milestone changed from Awaiting Review to 3.6

comment:3 ryan12 months ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In 24198:

Avoid warning in gallery_shortcode() when called outside of post context.

Props kovshenin
fixes #24272

comment:4 SergeyBiryukov8 weeks ago

#20870 was marked as a duplicate.

Note: See TracTickets for help on using tickets.