r53104 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r53103 | r53104 (on ViewVC) | r53105 >
Date:08:04, 11 July 2009
Author:midom
Status:resolved
Tags:
Comment:Fix Bug#19637 - self-referencing externals will be by default filtered out
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/parser/ParserOutput.php
===================================================================
--- trunk/phase3/includes/parser/ParserOutput.php	(revision 53103)
+++ trunk/phase3/includes/parser/ParserOutput.php	(revision 53104)
@@ -74,7 +74,6 @@
 
 	function addCategory( $c, $sort )    { $this->mCategories[$c] = $sort; }
 	function addLanguageLink( $t )       { $this->mLanguageLinks[] = $t; }
-	function addExternalLink( $url )     { $this->mExternalLinks[$url] = 1; }
 	function addWarning( $s )            { $this->mWarnings[$s] = 1; }
 
 	function addOutputHook( $hook, $data = false ) {
@@ -94,6 +93,13 @@
 		return (bool)$this->mNewSection;
 	}
 
+	function addExternalLink( $url ) {
+		# We don't register links pointing to our own server, unless... :-)
+		global $wgServer, $wgRegisterInternalExternals;
+		if( $wgRegisterInternalExternals or stripos($url,$wgServer)!==0)
+			$this->mExternalLinks[$url] = 1; 
+	}
+
 	function addLink( $title, $id = null ) {
 		$ns = $title->getNamespace();
 		$dbk = $title->getDBkey();
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 53103)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 53104)
@@ -3753,6 +3753,12 @@
 $wgLinkHolderBatchSize = 1000;
 
 /**
+ * By default MediaWiki does not register links pointing to same server in externallinks dataset,
+ * use this value to override:
+ */
+$wgRegisterInternalExternals = false;
+
+/**
  * Hooks that are used for outputting exceptions.  Format is:
  *   $wgExceptionHooks[] = $funcname
  * or:
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 53103)
+++ trunk/phase3/RELEASE-NOTES	(revision 53104)
@@ -52,6 +52,8 @@
   functionality is now available via $wgLocalisationCacheConf.
 * $wgMessageCache->addMessages() is deprecated. Messages added via this 
   interface will not appear in Special:AllMessages.
+* $wgRegisterInternalExternals can be used to record external links pointing 
+  to same server
 
 === New features in 1.16 ===
 
@@ -238,6 +240,7 @@
 * (bug 19468) Enotif preferences are now only displayed when they are turned on
 * (bug 19442) Show/hide options on watchlist only work once
 * (bug 19602) PubMed Magic links now use updated NIH url
+* (bug 19637) externallinks have links to self
 
 == API changes in 1.16 ==
 

Status & tagging log

Views
Toolbox