Opened 8 years ago
Last modified 3 months ago
#44394 new defect (bug)
Error when trying to get the columns of a three-columns gallery.
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | 4.9.6 |
| Component: | Gallery | Keywords: | has-patch changes-requested reporter-feedback |
| 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)
Change History (4)
#1
@
8 years ago
Version 0, edited 8 years ago
by
(next)
#2
@
8 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.
#3
@
3 months ago
- Keywords changes-requested reporter-feedback added; needs-testing removed
Test Report
Description
This report validates whether the indicated patch works as expected.
Patch tested: https://core.trac.wordpress.org/attachment/ticket/44394/patch.diff
Environment
- WordPress: 7.0-alpha-61215-src
- PHP: 8.2.29
- Server: nginx/1.29.4
- Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.2.29)
- Browser: Chrome 143.0.0.0
- OS: macOS
- Theme: Twenty Twenty-One 2.7
- MU Plugins: None activated
- Plugins:
- Classic Editor 1.6.7
- Test Reports 1.2.1
Steps to Reproduce
- Install and active classic editor
- Add a new post
- Create a gallery with 3 images and choose 3 columns
- Add the following snippet to single.php
$gallery = get_post_gallery( $post->ID, False ); $gallery_images = explode( ',', $gallery['ids'] ); var_dump( $gallery['columns'] );
Actual Results
- ❌ Issue did not resolve with patch.
Additional Notes
- When I test the use case code provided by the reporter, I get the same error before and after applying the patch.
Supplemental Artifacts
Note: See
TracTickets for help on using
tickets.




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