r29801 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r29800‎ | r29801 | r29802 >
Date:16:08, 15 January 2008
Author:catrope
Status:old
Tags:
Comment:
API: Adding wlshow parameter to list=watchlist to allow for filtering (non-)minor, (non-)bot and (non-)anon edits
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryWatchlist.php
@@ -59,7 +59,7 @@
6060 if (!$wgUser->isLoggedIn())
6161 $this->dieUsage('You must be logged-in to have a watchlist', 'notloggedin');
6262
63 - $allrev = $start = $end = $namespace = $dir = $limit = $prop = null;
 63+ $allrev = $start = $end = $namespace = $dir = $limit = $prop = $show = null;
6464 extract($this->extractRequestParams());
6565
6666 if (!is_null($prop) && is_null($resultPageSet)) {
@@ -135,7 +135,28 @@
136136 $this->addWhereFld('wl_namespace', $namespace);
137137 $this->addWhereIf('rc_this_oldid=page_latest', !$allrev);
138138
139 - # This is a index optimization for mysql, as done in the Special:Watchlist page
 139+ if (!is_null($show)) {
 140+ $show = array_flip($show);
 141+
 142+ /* Check for conflicting parameters. */
 143+ if ((isset ($show['minor']) && isset ($show['!minor']))
 144+ || (isset ($show['bot']) && isset ($show['!bot']))
 145+ || (isset ($show['anon']) && isset ($show['!anon']))) {
 146+
 147+ $this->dieUsage("Incorrect parameter - mutually exclusive values may not be supplied", 'show');
 148+ }
 149+
 150+ /* Add additional conditions to query depending upon parameters. */
 151+ $this->addWhereIf('rc_minor = 0', isset ($show['!minor']));
 152+ $this->addWhereIf('rc_minor != 0', isset ($show['minor']));
 153+ $this->addWhereIf('rc_bot = 0', isset ($show['!bot']));
 154+ $this->addWhereIf('rc_bot != 0', isset ($show['bot']));
 155+ $this->addWhereIf('rc_user = 0', isset ($show['anon']));
 156+ $this->addWhereIf('rc_user != 0', isset ($show['!anon']));
 157+ }
 158+
 159+
 160+ # This is an index optimization for mysql, as done in the Special:Watchlist page
140161 $this->addWhereIf("rc_timestamp > ''", !isset ($start) && !isset ($end) && $wgDBtype == 'mysql');
141162
142163 $this->addOption('LIMIT', $limit +1);
@@ -262,6 +283,17 @@
263284 'patrol',
264285 'sizes',
265286 )
 287+ ),
 288+ 'show' => array (
 289+ ApiBase :: PARAM_ISMULTI => true,
 290+ ApiBase :: PARAM_TYPE => array (
 291+ 'minor',
 292+ '!minor',
 293+ 'bot',
 294+ '!bot',
 295+ 'anon',
 296+ '!anon'
 297+ )
266298 )
267299 );
268300 }
@@ -274,7 +306,11 @@
275307 'namespace' => 'Filter changes to only the given namespace(s).',
276308 'dir' => 'In which direction to enumerate pages.',
277309 'limit' => 'How many total pages to return per request.',
278 - 'prop' => 'Which additional items to get (non-generator mode only).'
 310+ 'prop' => 'Which additional items to get (non-generator mode only).',
 311+ 'show' => array (
 312+ 'Show only items that meet this criteria.',
 313+ 'For example, to see only minor edits done by logged-in users, set show=minor|!anon'
 314+ )
279315 );
280316 }
281317
Index: trunk/phase3/RELEASE-NOTES
@@ -435,6 +435,7 @@
436436 * Add list of sections to action=parse output
437437 * Added action=logout
438438 * Added cascade flag to prop=info&inprop=protections
 439+* Added wlshow parameter to list=watchlist, similar to rcshow (list=recentchanges)
439440
440441 === Languages updated in 1.12 ===
441442

Status & tagging log