From 7722bc1314ab177835be11358375c817dbca8258 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 4 Sep 2007 14:44:46 +0000 Subject: [PATCH] (bug 10980) Add exclude redirects on backlinks --- RELEASE-NOTES | 1 + includes/api/ApiQueryBacklinks.php | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e6e41c62cf..7f768f11a7 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -497,6 +497,7 @@ Full API documentation is available at http://www.mediawiki.org/wiki/API * (bug 11115) Adding SHA1 hash to imageinfo query * (bug 10898) API does not return an edit token for non-existent pages * (bug 10890) Timestamp support for categorymembers query +* (bug 10980) Add exclude redirects on backlinks == Maintenance script changes since 1.10 == diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index b4f4380dfe..7e4bb721a1 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -102,7 +102,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $redirect = $this->params['redirect']; if ($redirect) - ApiBase :: dieDebug(__METHOD__, 'Redirect has not been implemented', 'notimplemented'); + $this->dieDebug('Redirect has not been implemented', 'notimplemented'); $this->processContinue(); @@ -124,13 +124,15 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $this->addWhereFld($this->bl_title, $this->rootTitle->getDBkey()); $this->addWhereFld('page_namespace', $this->params['namespace']); + if($this->params['filterredir'] == 'redirects') + $this->addWhereFld('page_is_redirect', 1); + if($this->params['filterredir'] == 'nonredirects') + $this->addWhereFld('page_is_redirect', 0); + $limit = $this->params['limit']; $this->addOption('LIMIT', $limit +1); $this->addOption('ORDER BY', $this->bl_sort); - if ($redirect) - $this->addWhereFld('page_is_redirect', 0); - $db = $this->getDB(); if (!is_null($this->params['continue'])) { $plfrm = intval($this->contID); @@ -322,6 +324,14 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { ApiBase :: PARAM_ISMULTI => true, ApiBase :: PARAM_TYPE => 'namespace' ), + 'filterredir' => array( + ApiBase :: PARAM_DFLT => 'all', + ApiBase :: PARAM_TYPE => array( + 'all', + 'redirects', + 'nonredirects' + ) + ), 'redirect' => false, 'limit' => array ( ApiBase :: PARAM_DFLT => 10, @@ -338,6 +348,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { 'title' => 'Title to search. If null, titles= parameter will be used instead, but will be obsolete soon.', 'continue' => 'When more results are available, use this to continue.', 'namespace' => 'The namespace to enumerate.', + 'filterredir' => 'How to filter for redirects', 'redirect' => 'If linking page is a redirect, find all pages that link to that redirect (not implemented)', 'limit' => 'How many total pages to return.' ); -- 2.20.1