Make WordPress Core

Opened 12 years ago

Closed 11 years ago

#24270 closed defect (bug) (fixed)

Post Formats: get_post_gallery() can return an array when asked for a string

Reported by: kovshenin's profile kovshenin Owned by: markjaquith's profile markjaquith
Milestone: 3.6 Priority: normal
Severity: normal Version: 3.6
Component: Post Formats Keywords: has-patch commit
Focuses: Cc:

Description (last modified by kovshenin)

If the requested post is not found or does not contain a gallery shortcode, get_post_gallery returns an empty array, regardless of what the $html argument is set to.

Attachments (4)

24270.diff (531 bytes) - added by kovshenin 12 years ago.
24270.2.diff (828 bytes) - added by kovshenin 12 years ago.
24270.3.diff (849 bytes) - added by wonderboymusic 11 years ago.
24270.4.diff (1.9 KB) - added by ocean90 11 years ago.

Download all attachments as: .zip

Change History (12)

@kovshenin
12 years ago

#1 @kovshenin
12 years ago

  • Keywords has-patch added

#2 @kovshenin
12 years ago

  • Description modified (diff)
  • Summary changed from Post Formats: get_post_galleries() can return an array when asked for a string to Post Formats: get_post_gallery() can return an array when asked for a string

@kovshenin
12 years ago

#3 @kovshenin
12 years ago

Sorry, blamed the wrong function :) get_post_gallery is the one and 24270.2.diff is the fix.

// The 9212 post has a gallery shortcode
echo gettype( get_post_gallery( 9212, false ) ); // array
echo gettype( get_post_gallery( 1, false ) ); // array
echo gettype( get_post_gallery( 9212, true ) ); // string
echo gettype( get_post_gallery( 1, true ) ); // array oO!

#4 @kovshenin
11 years ago

#24390 was marked as a duplicate.

#5 @kovshenin
11 years ago

The newer patch in #24390 applies cleanly.

#6 @wonderboymusic
11 years ago

  • Keywords commit added

my new patch applies cleanly and handles both cases 24270.3.diff

#7 @ocean90
11 years ago

I think that get_content_images() and get_content_galleries() should mention that $html is the type inside the array, which will be returned and isn't the same as for get_post_gallery().

@ocean90
11 years ago

#8 @markjaquith
11 years ago

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

In 24572:

Make sure get_post_gallery() doesn't ever return an array when asked for a string.

props kovshenin, wonderboymusic, ocean90. fixes #24270.

Note: See TracTickets for help on using tickets.