Make WordPress Core

Opened 6 years ago

Last modified 6 years ago

#44394 new defect (bug)

Error when trying to get the columns of a three-columns gallery.

Reported by: virginthumb's profile virginthumb Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.9.6
Component: Gallery Keywords: needs-testing has-patch
Focuses: Cc:


It seems the get_post_gallery function fails to retrieve the column count if it's 3.

First, create a gallery. Then, insert 2 or 3 or any number of images and set its column to 3.

Then, run this code in the context of a post (content.php / single.php will do):

$gallery = get_post_gallery( $post->ID, False );
$gallery_images = explode( ',', $gallery['ids'] );
var_dump( $gallery['columns'] );

It will come out as:

<b>Notice</b>:  Undefined index: columns in <b>C:\file.php</b> on line <b>45</b>

Attachments (1)

patch.diff (505 bytes) - added by saimonh 6 years ago.

Download all attachments as: .zip

Change History (3)

#1 @virginthumb
6 years ago

Big update.

Turns out this bug only happens when there are 2 galleries. Removing the second gallery fixes it, but still, get_post_gallery should get the first / "featured" gallery only.

Update 2:

Another user confirmed this.

Last edited 6 years ago by virginthumb (previous) (diff)

#2 @saimonh
6 years ago

  • Keywords has-patch added; needs-patch removed
  • Severity changed from minor to normal
  • Version set to 4.9.6

Yes, I can confirm this bug and have included a patch for this issue. Please have a look.

6 years ago

Note: See TracTickets for help on using tickets.