[wp-trac] [WordPress Trac] #39304: `get_post_galleries()` can return incorrect gallery items.

WordPress Trac noreply at wordpress.org
Fri Dec 16 07:27:37 UTC 2016


#39304: `get_post_galleries()` can return incorrect gallery items.
--------------------------+-----------------------------
 Reporter:  dd32          |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 `get_post_galleries()` is a little hacky in the way it works and doesn't
 work as intended when a  plain `[gallery]` shortcode is within the content
 and the given post_id doesn't match the global `$post` object.

 For example, take the following scenario:
 {{{
 post_content = [gallery]
 $GLOBALS['post'] = null;
 $data = get_post_galleries( $id );
 }}}

 `$data` now contains a gallery of all ''unattached'' media, as the
 shortcode handler doesn't have the global `$post` context and instead
 queries for `post_parent = 0`.

 If the global `$post` was set to another post, the gallery would be of
 that posts media.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39304>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list