r42512 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r42511 | r42512 (on ViewVC) | r42513 >
Date:22:22, 24 October 2008
Author:catrope
Status:ok
Tags:api 
Comment:API: * Fix up r42471 which hardcoded pl_from instead of using $this->bl_from
* Fix the second half of bug 16076 (using pl_from>=123 in combination with multiple values for pl_namespace and pl_title causes filesort)
* By pure accident this fixes a bug about list=backlinks&blredirect dropping results under obscure conditions
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryBacklinks.php
===================================================================
--- trunk/phase3/includes/api/ApiQueryBacklinks.php	(revision 42511)
+++ trunk/phase3/includes/api/ApiQueryBacklinks.php	(revision 42512)
@@ -113,7 +113,7 @@
 			$this->addWhereFld($this->bl_ns, $this->rootTitle->getNamespace());
 		$this->addWhereFld('page_namespace', $this->params['namespace']);
 		if(!is_null($this->contID))
-			$this->addWhere("pl_from>={$this->contID}");
+			$this->addWhere("{$this->bl_from}>={$this->contID}");
 		if($this->params['filterredir'] == 'redirects')
 			$this->addWhereFld('page_is_redirect', 1);
 		if($this->params['filterredir'] == 'nonredirects')
@@ -147,7 +147,23 @@
 		$this->addWhere($titleWhere);
 		$this->addWhereFld('page_namespace', $this->params['namespace']);
 		if(!is_null($this->redirID))
-			$this->addWhere("pl_from>={$this->redirID}");
+		{
+			$first = $this->redirTitles[0];
+			$title = $db->strencode($first->getDBKey());
+			$ns = $first->getNamespace();
+			$from = $this->redirID;
+			if($this->hasNS)
+				$this->addWhere("{$this->bl_ns} > $ns OR ".
+						"({$this->bl_ns} = $ns AND ".
+						"({$this->bl_title} > '$title' OR ".
+						"({$this->bl_title} = '$title' AND ".
+						"{$this->bl_from} >= $from)))");
+			else
+				$this->addWhere("{$this->bl_title} > '$title' OR ".
+						"({$this->bl_title} = '$title' AND ".
+						"{$this->bl_from} >= $from)");
+				
+		}
 		if($this->params['filterredir'] == 'redirects')
 			$this->addWhereFld('page_is_redirect', 1);
 		if($this->params['filterredir'] == 'nonredirects')
Views
Toolbox