r37748 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37747‎ | r37748 | r37749 >
Date:15:42, 16 July 2008
Author:catrope
Status:old
Tags:
Comment:
(bug 14020) Added an API interface to Special:Unwatchedpages in the form of the apfilterwatched parameter to list=allpages. If $wgMiserMode is true or if the user doesn't have the 'unwatchedpages' right, apfilterwatched is ignored and a warning is output.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllpages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryAllpages.php
@@ -51,7 +51,6 @@
5252 }
5353
5454 private function run($resultPageSet = null) {
55 -
5655 $db = $this->getDB();
5756
5857 $params = $this->extractRequestParams();
@@ -97,6 +96,29 @@
9897 $this->dieUsage('prlevel may not be used without prtype', 'params');
9998 }
10099
 100+ // Only allow watched page filtering if the user has the 'unwatchedpages' permission
 101+ // $wgMiserMode disables this
 102+ global $wgUser, $wgMiserMode;
 103+ if ($wgUser->isAllowed('unwatchedpages') && !$wgMiserMode) {
 104+ if($params['filterwatched'] != 'all') {
 105+ $this->addTables('watchlist');
 106+ $this->addJoinConds(array('watchlist' => array('LEFT JOIN', array(
 107+ 'wl_namespace = page_namespace',
 108+ 'wl_title = page_title'))));
 109+ }
 110+ if($params['filterwatched'] == 'unwatched') {
 111+ $this->addWhere('wl_title IS NULL');
 112+ }
 113+ else if ($params['filterwatched'] == 'watched') {
 114+ $this->addWhere('wl_title IS NOT NULL');
 115+ }
 116+ }
 117+ else if($params['filterwatched'] != 'all') {
 118+ if($wgMiserMode)
 119+ $this->setWarning('apfilterwatched is disabled on this wiki for performance reasons');
 120+ else
 121+ $this->setWarning('You don\'t have permission to filter by watched status');
 122+ }
101123 if($params['filterlanglinks'] == 'withoutlanglinks') {
102124 $this->addTables('langlinks');
103125 $this->addJoinConds(array('langlinks' => array('LEFT JOIN', 'page_id=ll_from')));
@@ -108,7 +130,7 @@
109131 $forceNameTitleIndex = false;
110132 }
111133 if ($forceNameTitleIndex)
112 - $this->addOption('USE INDEX', 'name_title');
 134+ $this->addOption('USE INDEX', array('page' => 'name_title'));
113135
114136 if (is_null($resultPageSet)) {
115137 $this->addFields(array (
@@ -206,6 +228,14 @@
207229 'all'
208230 ),
209231 ApiBase :: PARAM_DFLT => 'all'
 232+ ),
 233+ 'filterwatched' => array(
 234+ ApiBase :: PARAM_TYPE => array(
 235+ 'watched',
 236+ 'unwatched',
 237+ 'all'
 238+ ),
 239+ ApiBase :: PARAM_DFLT => 'all'
210240 )
211241 );
212242 }
@@ -222,6 +252,7 @@
223253 'prtype' => 'Limit to protected pages only',
224254 'prlevel' => 'The protection level (must be used with apprtype= parameter)',
225255 'filterlanglinks' => 'Filter based on whether a page has langlinks',
 256+ 'filterwatched' => 'Filter based on whther a page is watched (requires \'unwatchedpages\' right)',
226257 'limit' => 'How many total pages to return.'
227258 );
228259 }
Index: trunk/phase3/RELEASE-NOTES
@@ -530,6 +530,7 @@
531531 * Added flag "top" to list=usercontribs if the user is the last contributor to
532532 the page
533533 * list=exturlusage in "list all links" mode can now filter by protocol
 534+* (bug 14020) Added apfilterwatched parameter to list=allpages
534535
535536 === Languages updated in 1.13 ===
536537

Follow-up revisions

RevisionCommit summaryAuthorDate
r37775Revert r37748 "(bug 14020) Added an API interface to Special:Unwatchedpages i...brion09:26, 17 July 2008

Status & tagging log