Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 12 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 Owned by: ryan
Priority: normal Milestone: 3.6
Component: Media Version:
Severity: normal Keywords: has-patch
Cc: Focuses:

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

Download all attachments as: .zip

Change History (5)

@kovshenin
13 years ago

#1 @kovshenin
13 years ago

  • Keywords has-patch added

#2 @ryan
13 years ago

  • Milestone Awaiting Review3.6

#3 @ryan
13 years ago

  • Owner set to ryan
  • Resolutionfixed
  • Status newclosed

In 24198:

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

Props kovshenin
fixes #24272

#4 @SergeyBiryukov
12 years ago

#20870 was marked as a duplicate.

Note: See TracTickets for help on using tickets.