From: Sam Reed Date: Sun, 13 Mar 2011 17:59:27 +0000 (+0000) Subject: Bug 27341 - Add drto param to list=deletedrevs X-Git-Tag: 1.31.0-rc.0~31455 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=d1d3e347756e96ea394ebba8237ebc966ca20198;p=lhc%2Fweb%2Fwiklou.git Bug 27341 - Add drto param to list=deletedrevs Tidy code up a little bit --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b7a98933fd..c97dfd7d3a 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -251,6 +251,7 @@ PHP if you have not done so prior to upgrading MediaWiki. * (bug 27340) API: Allow listing of "small" categories * (bug 27342) Add audir param to list=allusers * (bug 27203) add fato param to list=filearchive +* (bug 27341) Add drto param to list=deletedrevs === Languages updated in 1.18 === diff --git a/includes/api/ApiQueryDeletedrevs.php b/includes/api/ApiQueryDeletedrevs.php index c4b410c3ac..2cf5ee5788 100644 --- a/includes/api/ApiQueryDeletedrevs.php +++ b/includes/api/ApiQueryDeletedrevs.php @@ -128,6 +128,8 @@ class ApiQueryDeletedrevs extends ApiQueryBase { $token = $wgUser->editToken( '', $this->getMain()->getRequest() ); } + $dir = $params['dir']; + // We need a custom WHERE clause that matches all titles. if ( $mode == 'revs' ) { $lb = new LinkBatch( $titles ); @@ -135,10 +137,10 @@ class ApiQueryDeletedrevs extends ApiQueryBase { $this->addWhere( $where ); } elseif ( $mode == 'all' ) { $this->addWhereFld( 'ar_namespace', $params['namespace'] ); - if ( !is_null( $params['from'] ) ) { - $from = $this->getDB()->strencode( $this->titleToKey( $params['from'] ) ); - $this->addWhere( "ar_title >= '$from'" ); - } + + $from = is_null( $params['from'] ) ? null : $this->titleToKey( $params['from'] ); + $to = is_null( $params['to'] ) ? null : $this->titleToKey( $params['to'] ); + $this->addWhereRange( 'ar_title', $dir, $from, $to ); } if ( !is_null( $params['user'] ) ) { @@ -148,8 +150,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase { $this->getDB()->addQuotes( $params['excludeuser'] ) ); } - if ( !is_null( $params['continue'] ) && ( $mode == 'all' || $mode == 'revs' ) ) - { + if ( !is_null( $params['continue'] ) && ( $mode == 'all' || $mode == 'revs' ) ) { $cont = explode( '|', $params['continue'] ); if ( count( $cont ) != 3 ) { $this->dieUsage( 'Invalid continue param. You should pass the original value returned by the previous query', 'badcontinue' ); @@ -157,7 +158,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase { $ns = intval( $cont[0] ); $title = $this->getDB()->strencode( $this->titleToKey( $cont[1] ) ); $ts = $this->getDB()->strencode( $cont[2] ); - $op = ( $params['dir'] == 'newer' ? '>' : '<' ); + $op = ( $dir == 'newer' ? '>' : '<' ); $this->addWhere( "ar_namespace $op $ns OR " . "(ar_namespace = $ns AND " . "(ar_title $op '$title' OR " . @@ -170,17 +171,16 @@ class ApiQueryDeletedrevs extends ApiQueryBase { if ( $mode == 'all' ) { if ( $params['unique'] ) { $this->addOption( 'GROUP BY', 'ar_title' ); - $this->addOption( 'ORDER BY', 'ar_title' ); } else { - $this->addOption( 'ORDER BY', 'ar_title, ar_timestamp' ); + $this->addOption( 'ORDER BY', 'ar_timestamp' ); } } else { if ( $mode == 'revs' ) { // Sort by ns and title in the same order as timestamp for efficiency - $this->addWhereRange( 'ar_namespace', $params['dir'], null, null ); - $this->addWhereRange( 'ar_title', $params['dir'], null, null ); + $this->addWhereRange( 'ar_namespace', $dir, null, null ); + $this->addWhereRange( 'ar_title', $dir, null, null ); } - $this->addWhereRange( 'ar_timestamp', $params['dir'], $params['start'], $params['end'] ); + $this->addWhereRange( 'ar_timestamp', $dir, $params['start'], $params['end'] ); } $res = $this->select( __METHOD__ ); $pageMap = array(); // Maps ns&title to (fake) pageid @@ -273,6 +273,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase { ApiBase::PARAM_DFLT => 'older' ), 'from' => null, + 'to' => null, 'continue' => null, 'unique' => false, 'user' => array( @@ -315,6 +316,8 @@ class ApiQueryDeletedrevs extends ApiQueryBase { 'start' => 'The timestamp to start enumerating from (1,2)', 'end' => 'The timestamp to stop enumerating at (1,2)', 'dir' => $this->getDirectionDescription( $this->getModulePrefix(), ' (1,2)' ), + 'from' => 'Start listing at this title (3)', + 'to' => 'Stop listing at this title (3)', 'limit' => 'The maximum amount of revisions to list', 'prop' => array( 'Which properties to get', @@ -331,7 +334,6 @@ class ApiQueryDeletedrevs extends ApiQueryBase { 'namespace' => 'Only list pages in this namespace (3)', 'user' => 'Only list revisions by this user', 'excludeuser' => 'Don\'t list revisions by this user', - 'from' => 'Start listing at this title (3)', 'continue' => 'When more results are available, use this to continue (3)', 'unique' => 'List only one revision for each page (3)', );