Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 9 years 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's profile kovshenin Owned by: ryan's profile ryan
Milestone: 3.6 Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch
Focuses: Cc:

Description

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 10 years ago.

Download all attachments as: .zip

Change History (5)

@kovshenin
10 years ago

#1 @kovshenin
10 years ago

  • Keywords has-patch added

#2 @ryan
10 years ago

  • Milestone changed from Awaiting Review to 3.6

#3 @ryan
10 years 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

#4 @SergeyBiryukov
9 years ago

#20870 was marked as a duplicate.

Note: See TracTickets for help on using tickets.