Page MenuHomePhabricator

api_wr_desc.patch

Authored By
bzimport
Nov 22 2014, 12:02 AM
Size
1 KB
Referenced Files
None
Subscribers
None

api_wr_desc.patch

Index: includes/api/ApiQueryWatchlistRaw.php
===================================================================
--- includes/api/ApiQueryWatchlistRaw.php (revision 106529)
+++ includes/api/ApiQueryWatchlistRaw.php (working copy)
@@ -77,18 +77,20 @@
}
$ns = intval( $cont[0] );
$title = $this->getDB()->strencode( $this->titleToKey( $cont[1] ) );
+ $op = $params['dir'] == 'ascending' ? '>' : '<';
$this->addWhere(
- "wl_namespace > '$ns' OR " .
+ "wl_namespace $op '$ns' OR " .
"(wl_namespace = '$ns' AND " .
- "wl_title >= '$title')"
+ "wl_title $op= '$title')"
);
}
// Don't ORDER BY wl_namespace if it's constant in the WHERE clause
+ $sort = $params['dir'] == 'descending' ? ' DESC' : '';
if ( count( $params['namespace'] ) == 1 ) {
- $this->addOption( 'ORDER BY', 'wl_title' );
+ $this->addOption( 'ORDER BY', 'wl_title' . $sort );
} else {
- $this->addOption( 'ORDER BY', 'wl_namespace, wl_title' );
+ $this->addOption( 'ORDER BY', 'wl_namespace' . $sort . ', wl_title' . $sort );
}
$this->addOption( 'LIMIT', $params['limit'] + 1 );
$res = $this->select( __METHOD__ );
@@ -160,7 +162,14 @@
),
'token' => array(
ApiBase::PARAM_TYPE => 'string'
- )
+ ),
+ 'dir' => array(
+ ApiBase::PARAM_DFLT => 'ascending',
+ ApiBase::PARAM_TYPE => array(
+ 'ascending',
+ 'descending'
+ ),
+ ),
);
}
@@ -176,6 +185,7 @@
'show' => 'Only list items that meet these criteria',
'owner' => 'The name of the user whose watchlist you\'d like to access',
'token' => 'Give a security token (settable in preferences) to allow access to another user\'s watchlist',
+ 'dir' => 'Direction to sort the titles in',
);
}

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
8052
Default Alt Text
api_wr_desc.patch (1 KB)

Event Timeline