WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#20315 closed defect (bug) (invalid)

Remove unused code in media.php

Reported by: arena Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.9
Component: Embeds Keywords: close
Focuses: Cc:
PR Number:

Description

linkifunknown variable is useless because always false when tested !

wp-includes/media.php:1029:	var $linkifunknown = true;
wp-includes/media.php:1276:		$oldval = $this->linkifunknown;
wp-includes/media.php:1277:		$this->linkifunknown = false;
wp-includes/media.php:1279:		$this->linkifunknown = $oldval;
wp-includes/media.php:1291:		$output = ( $this->linkifunknown ) ? '<a href="' . esc_attr($url) . '">' . esc_html($url) . '</a>' : $url;

Change History (3)

#1 @kurtpayne
8 years ago

  • Cc kpayne@… added
  • Keywords close added
  • Summary changed from code cleaning to Remove unused code in media.php

It's not immediately clear what's going on, but it's definitely not dead code.

It's first declared as true:

var $linkifunknown = true;

Then a shortcode named 'embed' is added:

add_shortcode( 'embed', array(&$this, 'shortcode') );

In the shortcode method, a maybe_make_link method is called, which uses $linkifunknown. It's true here.

$output = ( $this->linkifunknown ) ? '<a href="' . esc_attr($url) . '">' . esc_html($url) . '</a>' : $url;

$linkifunknown is only false when called from autoembed_callback.

function autoembed_callback( $match ) {
	$oldval = $this->linkifunknown;
	$this->linkifunknown = false;
	$return = $this->shortcode( array(), $match[1] );
	$this->linkifunknown = $oldval;
	return "\n$return\n";
}

When shortcode is called from autoembed_callback, $linkifunknown is false.

#2 @kurtpayne
8 years ago

  • Version changed from 3.4 to 2.9

#3 @SergeyBiryukov
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.