From: Siebrand Date: Sun, 1 Jul 2012 15:03:20 +0000 (+0000) Subject: Merge "(bug 32348) Allow descending order for list=alllinks" X-Git-Tag: 1.31.0-rc.0~23182 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=d842a5582fa2086e28c6fc5b70d2ee4bb5fd239f;hp=6b3c29c568194fb1abbf364568cb3eb6a73e0122;p=lhc%2Fweb%2Fwiklou.git Merge "(bug 32348) Allow descending order for list=alllinks" --- diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index a0dc046f49..23b4e78cbb 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -150,6 +150,7 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki. * (bug 36761) "Mark pages as visited" now submits previously established filter options * (bug 32643) action=purge with forcelinkupdate no longer crashes when ratelimit is reached * The paraminfo module now also contains result properties for most modules +* (bug 32348) Allow descending order for list=alllinks === Languages updated in 1.20 === diff --git a/includes/api/ApiQueryAllLinks.php b/includes/api/ApiQueryAllLinks.php index 6b8fe57f39..70b6656236 100644 --- a/includes/api/ApiQueryAllLinks.php +++ b/includes/api/ApiQueryAllLinks.php @@ -80,12 +80,13 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { if ( count( $continueArr ) != 2 ) { $this->dieUsage( 'Invalid continue parameter', 'badcontinue' ); } + $op = $params['dir'] == 'descending' ? '<' : '>'; $continueTitle = $db->addQuotes( $this->titleToKey( $continueArr[0] ) ); $continueFrom = intval( $continueArr[1] ); $this->addWhere( - "pl_title > $continueTitle OR " . + "pl_title $op $continueTitle OR " . "(pl_title = $continueTitle AND " . - "pl_from > $continueFrom)" + "pl_from $op= $continueFrom)" ); } @@ -104,12 +105,13 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { $limit = $params['limit']; $this->addOption( 'LIMIT', $limit + 1 ); + $sort = ( $params['dir'] == 'descending' ? ' DESC' : '' ); + $orderBy = array(); + $orderBy[] = 'pl_title' . $sort; if ( !$params['unique'] ) { - $this->addOption( 'ORDER BY', array( - 'pl_title', - 'pl_from' - )); + $orderBy[] = 'pl_from' . $sort; } + $this->addOption( 'ORDER BY', $orderBy ); $res = $this->select( __METHOD__ ); @@ -183,7 +185,14 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { ApiBase::PARAM_MIN => 1, ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 - ) + ), + 'dir' => array( + ApiBase::PARAM_DFLT => 'ascending', + ApiBase::PARAM_TYPE => array( + 'ascending', + 'descending' + ) + ), ); } @@ -202,6 +211,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { 'namespace' => 'The namespace to enumerate', 'limit' => 'How many total links to return', 'continue' => 'When more results are available, use this to continue', + 'dir' => 'The direction in which to list', ); }