r41406 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41405‎ | r41406 | r41407 >
Date:00:14, 30 September 2008
Author:brion
Status:old (Comments)
Tags:
Comment:
Back out r41333 -- causes lots of parser test regressions due to funny spacing. Probably an easy fix but it wasn't tested apparently. :)
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/includes/parser/ParserOptions.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser_OldPP.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES
@@ -140,8 +140,6 @@
141141 restriction types on the protection form.
142142 * (bug 8440) Allow preventing blocked users from editing their talk pages
143143 * Improved upload file type detection for OpenDocument formats
144 -* Added the ability to set the target attribute on external links with
145 - $wgExternalLinkTarget
146144 * (bug 368) Don't use caption for alt attribute; allow manual specification
147145 using new "alt=" parameter for images
148146
Index: trunk/phase3/includes/Linker.php
@@ -990,10 +990,11 @@
991991 }
992992
993993 /** @todo document */
994 - function makeExternalLink( $url, $text, $escape = true, $linktype = '', $attribs = array() ) {
995 - $attribsText = $this->getExternalLinkAttributes( $url, $text, 'external ' . $linktype );
996 - if ( $attribs ) {
997 - $attribsText .= ' ' . Xml::expandAttributes( $attribs );
 994+ function makeExternalLink( $url, $text, $escape = true, $linktype = '', $ns = null ) {
 995+ $style = $this->getExternalLinkAttributes( $url, $text, 'external ' . $linktype );
 996+ global $wgNoFollowLinks, $wgNoFollowNsExceptions;
 997+ if( $wgNoFollowLinks && !(isset($ns) && in_array($ns, $wgNoFollowNsExceptions)) ) {
 998+ $style .= ' rel="nofollow"';
998999 }
9991000 $url = htmlspecialchars( $url );
10001001 if( $escape ) {
@@ -1005,7 +1006,7 @@
10061007 wfDebug("Hook LinkerMakeExternalLink changed the output of link with url {$url} and text {$text} to {$link}", true);
10071008 return $link;
10081009 }
1009 - return '<a href="'.$url.'"'.$attribsText.'>'.$text.'</a>';
 1010+ return '<a href="'.$url.'"'.$style.'>'.$text.'</a>';
10101011 }
10111012
10121013 /**
Index: trunk/phase3/includes/parser/ParserOptions.php
@@ -30,7 +30,6 @@
3131 var $mTemplateCallback; # Callback for template fetching
3232 var $mEnableLimitReport; # Enable limit report in an HTML comment on output
3333 var $mTimestamp; # Timestamp used for {{CURRENTDAY}} etc.
34 - var $mExternalLinkTarget; # Target attribute for external links
3534
3635 var $mUser; # Stored user object, just used to initialise the skin
3736
@@ -53,7 +52,6 @@
5453 function getTemplateCallback() { return $this->mTemplateCallback; }
5554 function getEnableLimitReport() { return $this->mEnableLimitReport; }
5655 function getCleanSignatures() { return $this->mCleanSignatures; }
57 - function getExternalLinkTarget() { return $this->mExternalLinkTarget; }
5856
5957 function getSkin() {
6058 if ( !isset( $this->mSkin ) ) {
@@ -98,7 +96,6 @@
9997 function enableLimitReport( $x = true ) { return wfSetVar( $this->mEnableLimitReport, $x ); }
10098 function setTimestamp( $x ) { return wfSetVar( $this->mTimestamp, $x ); }
10199 function setCleanSignatures( $x ) { return wfSetVar( $this->mCleanSignatures, $x ); }
102 - function setExternalLinkTarget( $x ) { return wfSetVar( $this->mExternalLinkTarget, $x ); }
103100
104101 function __construct( $user = null ) {
105102 $this->initialiseFromUser( $user );
@@ -117,7 +114,6 @@
118115 global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
119116 global $wgAllowExternalImagesFrom, $wgEnableImageWhitelist, $wgAllowSpecialInclusion, $wgMaxArticleSize;
120117 global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth, $wgCleanSignatures;
121 - global $wgExternalLinkTarget;
122118 $fname = 'ParserOptions::initialiseFromUser';
123119 wfProfileIn( $fname );
124120 if ( !$userInput ) {
@@ -155,7 +151,6 @@
156152 $this->mTemplateCallback = array( 'Parser', 'statelessFetchTemplate' );
157153 $this->mEnableLimitReport = false;
158154 $this->mCleanSignatures = $wgCleanSignatures;
159 - $this->mExternalLinkTarget = $wgExternalLinkTarget;
160155 wfProfileOut( $fname );
161156 }
162157 }
Index: trunk/phase3/includes/parser/Parser_OldPP.php
@@ -1353,7 +1353,7 @@
13541354 # This means that users can paste URLs directly into the text
13551355 # Funny characters like &ouml; aren't valid in URLs anyway
13561356 # This was changed in August 2004
1357 - $s .= $sk->makeExternalLink( $url, $text, false, $linktype, $this->getExternalLinkAttribs() ) . $dtrail . $trail;
 1357+ $s .= $sk->makeExternalLink( $url, $text, false, $linktype, $this->mTitle->getNamespace() ) . $dtrail . $trail;
13581358
13591359 # Register link in the output object.
13601360 # Replace unnecessary URL escape codes with the referenced character
@@ -1366,19 +1366,6 @@
13671367 return $s;
13681368 }
13691369
1370 - function getExternalLinkAttribs() {
1371 - $attribs = array();
1372 - global $wgNoFollowLinks, $wgNoFollowNsExceptions;
1373 - $ns = $this->mTitle->getNamespace();
1374 - if( $wgNoFollowLinks && !in_array($ns, $wgNoFollowNsExceptions) ) {
1375 - $attribs['rel'] = 'nofollow';
1376 - }
1377 - if ( $this->mOptions->getExternalLinkTarget() ) {
1378 - $attribs['target'] = $this->mOptions->getExternalLinkTarget();
1379 - }
1380 - return $attribs;
1381 - }
1382 -
13831370 /**
13841371 * Replace anything that looks like a URL with a link
13851372 * @private
@@ -1445,8 +1432,7 @@
14461433 $text = $this->maybeMakeExternalImage( $url );
14471434 if ( $text === false ) {
14481435 # Not an image, make a link
1449 - $text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free',
1450 - $this->getExternalLinkAttribs() );
 1436+ $text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free', $this->mTitle->getNamespace() );
14511437 # Register it in the output object...
14521438 # Replace unnecessary URL escape codes with their equivalent characters
14531439 $pasteurized = self::replaceUnusualEscapes( $url );
Index: trunk/phase3/includes/parser/Parser.php
@@ -1118,8 +1118,7 @@
11191119 $text = $this->maybeMakeExternalImage( $url );
11201120 if ( $text === false ) {
11211121 # Not an image, make a link
1122 - $text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free',
1123 - $this->getExternalLinkAttribs() );
 1122+ $text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free', $this->mTitle->getNamespace() );
11241123 # Register it in the output object...
11251124 # Replace unnecessary URL escape codes with their equivalent characters
11261125 $pasteurized = self::replaceUnusualEscapes( $url );
@@ -1395,18 +1394,11 @@
13961395
13971396 $url = Sanitizer::cleanUrl( $url );
13981397
1399 - if ( $this->mOptions->mExternalLinkTarget ) {
1400 - $attribs = array( 'target' => $this->mOptions->mExternalLinkTarget );
1401 - } else {
1402 - $attribs = array();
1403 - }
1404 -
14051398 # Use the encoded URL
14061399 # This means that users can paste URLs directly into the text
14071400 # Funny characters like &ouml; aren't valid in URLs anyway
14081401 # This was changed in August 2004
1409 - $s .= $sk->makeExternalLink( $url, $text, false, $linktype, $this->getExternalLinkAttribs() )
1410 - . $dtrail . $trail;
 1402+ $s .= $sk->makeExternalLink( $url, $text, false, $linktype, $this->mTitle->getNamespace() ) . $dtrail . $trail;
14111403
14121404 # Register link in the output object.
14131405 # Replace unnecessary URL escape codes with the referenced character
@@ -1419,20 +1411,6 @@
14201412 return $s;
14211413 }
14221414
1423 - function getExternalLinkAttribs() {
1424 - $attribs = array();
1425 - global $wgNoFollowLinks, $wgNoFollowNsExceptions;
1426 - $ns = $this->mTitle->getNamespace();
1427 - if( $wgNoFollowLinks && !in_array($ns, $wgNoFollowNsExceptions) ) {
1428 - $attribs['rel'] = 'nofollow';
1429 - }
1430 - if ( $this->mOptions->getExternalLinkTarget() ) {
1431 - $attribs['target'] = $this->mOptions->getExternalLinkTarget();
1432 - }
1433 - return $attribs;
1434 - }
1435 -
1436 -
14371415 /**
14381416 * Replace unusual URL escape codes with their equivalent characters
14391417 * @param string
Index: trunk/phase3/includes/DefaultSettings.php
@@ -2891,11 +2891,6 @@
28922892 $wgSearchForwardUrl = null;
28932893
28942894 /**
2895 - * Set a default target for external links, e.g. _blank to pop up a new window
2896 - */
2897 -$wgExternalLinkTarget = false;
2898 -
2899 -/**
29002895 * If true, external URL links in wiki text will be given the
29012896 * rel="nofollow" attribute as a hint to search engines that
29022897 * they should not be followed for ranking purposes as they

Follow-up revisions

RevisionCommit summaryAuthorDate
r41409Revert revert r41406 of r41333, and removed one space between attributes.tstarling01:00, 30 September 2008

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r41333* Added the ability to set the target attribute on external links with $wgExt...tstarling02:35, 28 September 2008

Comments

#Comment by Brion VIBBER (talk | contribs)   01:03, 1 October 2008

Put back and fixed in r41409

Status & tagging log