From: mrbluesky Date: Thu, 29 Mar 2012 21:15:32 +0000 (+0200) Subject: (bug 32384) API: Allow descending order for list=watchlistraw X-Git-Tag: 1.31.0-rc.0~24067^2 X-Git-Url: http://git.cyclocoop.org/data/Fool?a=commitdiff_plain;h=c4654f3fb267498f89776f0ebd34626defd64882;p=lhc%2Fweb%2Fwiklou.git (bug 32384) API: Allow descending order for list=watchlistraw Patchset2: add parentheses around conditional expression Change-Id: Ibfc3cdce6a0f30f2086ede9fb91030ded174a1fb --- diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index 5e42184611..6220cd1f80 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -59,6 +59,7 @@ production. * (bug 34316) Add ability to retrieve maximum upload size from MediaWiki API. * (bug 34313) MediaWiki API intro message about "HTML format" should mention the format parameter. +* (bug 32384) Allow descending order for list=watchlistraw === Languages updated in 1.20 === diff --git a/includes/api/ApiQueryWatchlistRaw.php b/includes/api/ApiQueryWatchlistRaw.php index 506944f0b3..4adadf1e32 100644 --- a/includes/api/ApiQueryWatchlistRaw.php +++ b/includes/api/ApiQueryWatchlistRaw.php @@ -77,18 +77,20 @@ class ApiQueryWatchlistRaw extends ApiQueryGeneratorBase { } $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')" ); } + $sort = ( $params['dir'] == 'descending' ? ' DESC' : '' ); // Don't ORDER BY wl_namespace if it's constant in the WHERE clause 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 @@ class ApiQueryWatchlistRaw extends ApiQueryGeneratorBase { ), 'token' => array( ApiBase::PARAM_TYPE => 'string' - ) + ), + 'dir' => array( + ApiBase::PARAM_DFLT => 'ascending', + ApiBase::PARAM_TYPE => array( + 'ascending', + 'descending' + ), + ), ); } @@ -176,6 +185,7 @@ class ApiQueryWatchlistRaw extends ApiQueryGeneratorBase { '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 and namespaces in', ); }