Make WordPress Core

Opened 12 years ago

Closed 10 years ago

Last modified 10 years ago

#20870 closed defect (bug) (duplicate)

error notice when $post = NULL with gallery_shortcode

Reported by: thomask's profile thomask Owned by:
Milestone: Priority: normal
Severity: trivial Version: 3.3
Component: Media Keywords:
Focuses: Cc:


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;

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

#1 @nacin
12 years ago

  • Version changed from 3.4 to 3.3

#2 @wonderboymusic
10 years ago

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

This has since been fixed.

#3 @SergeyBiryukov
10 years ago

  • Resolution changed from fixed to duplicate

Duplicate of #24272.

#4 @SergeyBiryukov
10 years ago

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