Opened 14 months ago
Closed 14 months ago
#20315 closed defect (bug) (invalid)
Remove unused code in media.php
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Embeds | Version: | 2.9 |
| Severity: | normal | Keywords: | close |
| Cc: | kpayne@… |
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)
- Cc kpayne@… added
- Keywords close added
- Summary changed from code cleaning to Remove unused code in media.php
comment:3
SergeyBiryukov — 14 months ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
Note: See
TracTickets for help on using
tickets.

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.