From a901d184dd2d57b331361a5e78380e78aee3fa47 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Fri, 24 Oct 2008 22:22:40 +0000 Subject: [PATCH] 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 --- includes/api/ApiQueryBacklinks.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index efc1a91b16..258a482c0a 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -113,7 +113,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $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 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $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') -- 2.20.1