From 01e257cbd515bf3b43f9365e6611c784598ec113 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sat, 23 Jan 2010 21:28:27 +0000 Subject: [PATCH] Normalise check for filterredir in Allpages to that of backlinks Add a couple of blank lines --- includes/api/ApiQueryAllpages.php | 9 +++++++-- includes/api/ApiQueryBacklinks.php | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/api/ApiQueryAllpages.php b/includes/api/ApiQueryAllpages.php index 4f8fe40dca..0d3572adce 100644 --- a/includes/api/ApiQueryAllpages.php +++ b/includes/api/ApiQueryAllpages.php @@ -58,12 +58,17 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase { // Page filters $this->addTables( 'page' ); - if ( !$this->addWhereIf( 'page_is_redirect = 1', $params['filterredir'] === 'redirects' ) ) - $this->addWhereIf( 'page_is_redirect = 0', $params['filterredir'] === 'nonredirects' ); + + if ( $this->params['filterredir'] == 'redirects' ) + $this->addWhereFld( 'page_is_redirect', 1 ); + else if ( $this->params['filterredir'] == 'nonredirects' ) + $this->addWhereFld( 'page_is_redirect', 0 ); + $this->addWhereFld( 'page_namespace', $params['namespace'] ); $dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' ); $from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) ); $this->addWhereRange( 'page_title', $dir, $from, null ); + if ( isset ( $params['prefix'] ) ) $this->addWhere( 'page_title' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index e5b0d3a41d..6b4ee3fa06 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -116,10 +116,12 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $this->addWhereFld( 'page_namespace', $this->params['namespace'] ); if ( !is_null( $this->contID ) ) $this->addWhere( "{$this->bl_from}>={$this->contID}" ); + if ( $this->params['filterredir'] == 'redirects' ) $this->addWhereFld( 'page_is_redirect', 1 ); else if ( $this->params['filterredir'] == 'nonredirects' ) $this->addWhereFld( 'page_is_redirect', 0 ); + $this->addOption( 'LIMIT', $this->params['limit'] + 1 ); $this->addOption( 'ORDER BY', $this->bl_from ); $this->addOption( 'STRAIGHT_JOIN' ); -- 2.20.1