WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 16 months ago

Last modified 15 months ago

#20870 closed defect (bug) (duplicate)

error notice when $post = NULL with gallery_shortcode

Reported by: thomask 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)

comment:1 @nacin3 years ago

  • Version changed from 3.4 to 3.3

comment:2 @wonderboymusic16 months ago

  • Resolution set to fixed
  • Status changed from new to closed

This has since been fixed.

comment:3 @SergeyBiryukov15 months ago

  • Resolution changed from fixed to duplicate

Duplicate of #24272.

comment:4 @SergeyBiryukov15 months ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.