#20870 closed defect (bug) (duplicate)
error notice when $post = NULL with gallery_shortcode
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | trivial | Version: | 3.3 |
Component: | Media | Keywords: | |
Focuses: | Cc: |
Description
i have noticed with many relevant plugins and functions it may happen, that gallery_shortcode is called when global $post returns NULL. problem is, that gallery_shortcode function media.php containts
'id' => $post->ID,
(row 798 on 3.4 or 783 on 3.3.2) so when $post is NULL it returns error notice
there is trivial solution - adding (!$post) check just after the $output filter (so it could be rewriten by plugin authors) - see last line:
function gallery_shortcode($attr) { global $post; static $instance = 0; $instance++; // Allow plugins/themes to override the default gallery template. $output = apply_filters('post_gallery', '', $attr); if ( $output != '' ) return $output; if (!$post) return;
(sorry, i do not know how to change it on svn). This bug is even on 3.3.2 even on latest 3.4
Change History (4)
Note: See
TracTickets for help on using
tickets.
This has since been fixed.