Page MenuHomePhabricator

apiuser.patch

Authored By
bzimport
Nov 21 2014, 9:32 PM
Size
3 KB
Referenced Files
None
Subscribers
None

apiuser.patch

Index: includes/api/ApiQueryRevisions.php
===================================================================
--- includes/api/ApiQueryRevisions.php (revision 19656)
+++ includes/api/ApiQueryRevisions.php (arbetskopia)
@@ -36,14 +36,14 @@
}
public function execute() {
- $limit = $startid = $endid = $start = $end = $dir = $prop = null;
+ $limit = $startid = $endid = $start = $end = $dir = $prop = $onlyuser = $excludeuser = null;
extract($this->extractRequestParams());
// If any of those parameters are used, work in 'enumeration' mode.
// Enum mode can only be used when exactly one page is provided.
// Enumerating revisions on multiple pages make it extremelly
// difficult to manage continuations and require additional sql indexes
- $enumRevMode = (!is_null($limit) || !is_null($startid) || !is_null($endid) || $dir === 'newer' || !is_null($start) || !is_null($end));
+ $enumRevMode = (!is_null($onlyuser) || !is_null($excludeuser) || !is_null($limit) || !is_null($startid) || !is_null($endid) || $dir === 'newer' || !is_null($start) || !is_null($end));
$pageSet = $this->getPageSet();
$pageCount = $pageSet->getGoodTitleCount();
@@ -57,7 +57,7 @@
$this->dieUsage('The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).', 'revids');
if ($pageCount > 1 && $enumRevMode)
- $this->dieUsage('titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, start, and end parameters may only be used on a single page.', 'multpages');
+ $this->dieUsage('titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, onlyuser, excludeuser, start, and end parameters may only be used on a single page.', 'multpages');
$this->addTables('revision');
$this->addFields(array (
@@ -119,6 +119,13 @@
// There is only one ID, use it
$this->addWhereFld('rev_page', current(array_keys($pageSet->getGoodTitles())));
+
+ if( !is_null( $onlyuser ) ) {
+ $this->addWhere( 'rev_user_text = ' . $this->getDB()->addQuotes( $onlyuser ) );
+ } elseif ( !is_null( $excludeuser ) ) {
+ $this->addWhere( 'rev_user_text != ' . $this->getDB()->addQuotes( $excludeuser ) );
+ }
+
}
elseif ($pageCount > 0) {
// When working in multi-page non-enumeration mode,
@@ -221,7 +228,9 @@
'newer',
'older'
)
- )
+ ),
+ 'onlyuser' => null,
+ 'excludeuser' => null,
);
}
@@ -233,7 +242,9 @@
'endid' => 'stop revision enumeration on this revid (enum)',
'start' => 'from which revision timestamp to start enumeration (enum)',
'end' => 'enumerate up to this timestamp (enum)',
- 'dir' => 'direction of enumeration - towards "newer" or "older" revisions (enum)'
+ 'dir' => 'direction of enumeration - towards "newer" or "older" revisions (enum)',
+ 'onlyuser' => 'only include revisions made by user',
+ 'excludeuser' => 'exclude revisions made by user',
);
}
@@ -257,7 +268,12 @@
'Get first 5 revisions of the "Main Page":',
' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvdir=newer',
'Get first 5 revisions of the "Main Page" made after 2006-05-01:',
- ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvdir=newer&rvstart=20060501000000'
+ ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvdir=newer&rvstart=20060501000000',
+ 'Get first 5 revisions of the "Main Page" that isn\'t made made by anon/user "127.0.0.1"',
+ ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvexcludeuser=127.0.0.1',
+ 'Get first 5 revisions of the "Main Page" that was made by "user" "MediaWiki default"',
+ ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvonlyuser=MediaWiki%20default',
+
);
}

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3127
Default Alt Text
apiuser.patch (3 KB)

Event Timeline