WordPress.org

Make WordPress Core

Opened 5 weeks ago

Last modified 5 weeks ago

#44394 new defect (bug)

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

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

Description

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):

<?php
$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 5 weeks ago.

Download all attachments as: .zip

Change History (3)

#1 @virginthumb
5 weeks 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 5 weeks ago by virginthumb (previous) (diff)

#2 @saimonh
5 weeks 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.

@saimonh
5 weeks ago

Note: See TracTickets for help on using tickets.