WordPress.org

Make WordPress Core

#24270 closed defect (bug) (fixed)

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

Reported by: kovshenin Owned by: 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 14 months ago.
24270.2.diff (828 bytes) - added by kovshenin 14 months ago.
24270.3.diff (849 bytes) - added by wonderboymusic 13 months ago.
24270.4.diff (1.9 KB) - added by ocean90 12 months ago.

Download all attachments as: .zip

Change History (12)

kovshenin14 months ago

comment:1 kovshenin14 months ago

  • Keywords has-patch added

comment:2 kovshenin14 months 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

kovshenin14 months ago

comment:3 kovshenin14 months 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!

comment:4 kovshenin13 months ago

#24390 was marked as a duplicate.

comment:5 kovshenin13 months ago

The newer patch in #24390 applies cleanly.

wonderboymusic13 months ago

comment:6 wonderboymusic13 months ago

  • Keywords commit added

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

comment:7 ocean9013 months 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().

ocean9012 months ago

comment:8 markjaquith12 months 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.