Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F9134
patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 22 2014, 12:17 AM
2014-11-22 00:17:54 (UTC+0)
Size
2 KB
Referenced Files
None
Subscribers
None
patch
View Options
Index: ApiQueryUserContributions.php
===================================================================
--- ApiQueryUserContributions.php (révision 114273)
+++ ApiQueryUserContributions.php (copie de travail)
@@ -160,11 +160,19 @@
$encUser = $this->getDB()->strencode( $continue[0] );
$encTS = wfTimestamp( TS_MW, $continue[1] );
$op = ( $this->params['dir'] == 'older' ? '<' : '>' );
- $this->addWhere(
- "rev_user_text $op '$encUser' OR " .
- "(rev_user_text = '$encUser' AND " .
- "rev_timestamp $op= '$encTS')"
- );
+ if($this->params['sort'] == 'timestamp') {
+ $this->addWhere(
+ "rev_timestamp $op '$encTS' OR " .
+ "(rev_timestamp = '$encTS' AND " .
+ "rev_user_text $op= '$encUser')"
+ );
+ } else {
+ $this->addWhere(
+ "rev_user_text $op '$encUser' OR " .
+ "(rev_user_text = '$encUser' AND " .
+ "rev_timestamp $op= '$encTS')"
+ );
+ }
}
if ( !$wgUser->isAllowed( 'hideuser' ) ) {
@@ -179,11 +187,16 @@
// ... and in the specified timeframe.
// Ensure the same sort order for rev_user_text and rev_timestamp
// so our query is indexed
- if ( $this->multiUserMode ) {
+ // Either ordered by users,time
+ if ( $this->multiUserMode && $this->params['sort'] == 'user' ) {
$this->addWhereRange( 'rev_user_text', $this->params['dir'], null, null );
}
$this->addTimestampWhereRange( 'rev_timestamp',
$this->params['dir'], $this->params['start'], $this->params['end'] );
+ // Or by time,users
+ if ( $this->multiUserMode && $this->params['sort'] == 'timestamp' ) {
+ $this->addWhereRange( 'rev_user_text', $this->params['dir'], null, null );
+ }
$this->addWhereFld( 'page_namespace', $this->params['namespace'] );
$show = $this->params['show'];
@@ -415,6 +428,13 @@
)
),
'tag' => null,
+ 'sort' => array(
+ ApiBase::PARAM_DFLT => 'user',
+ ApiBase::PARAM_TYPE => array(
+ 'user',
+ 'timestamp'
+ )
+ ),
'toponly' => false,
);
}
@@ -446,6 +466,11 @@
'show' => array( "Show only items that meet this criteria, e.g. non minor edits only: {$p}show=!minor",
"NOTE: if {$p}show=patrolled or {$p}show=!patrolled is set, revisions older than $wgRCMaxAge won\'t be shown", ),
'tag' => 'Only list revisions tagged with this tag',
+ 'sort' => array(
+ 'Way to sort the query when querying with multiple users',
+ ' user (default) - Sort output by user, then by timestamp',
+ ' timestamp - Sort output by timestamp, then by user',
+ ),
'toponly' => 'Only list changes which are the latest revision',
);
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
8642
Default Alt Text
patch (2 KB)
Attached To
Mode
T37349: usercontribs API: sort results by timestamp,user or user,timestamp
Attached
Detach File
Event Timeline
Log In to Comment