Merge "[FileBackend] Made it easy to use registed file backend config in multi-write...
[lhc/web/wiklou.git] / includes / api / ApiQueryDeletedrevs.php
index 546e081..c25f561 100644 (file)
  * @file
  */
 
-if ( !defined( 'MEDIAWIKI' ) ) {
-       // Eclipse helper - will be ignored in production
-       require_once( 'ApiQueryBase.php' );
-}
-
 /**
  * Query module to enumerate all deleted revisions.
  *
@@ -58,6 +53,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
                $fld_parsedcomment = isset ( $prop['parsedcomment'] );
                $fld_minor = isset( $prop['minor'] );
                $fld_len = isset( $prop['len'] );
+               $fld_sha1 = isset( $prop['sha1'] );
                $fld_content = isset( $prop['content'] );
                $fld_token = isset( $prop['token'] );
 
@@ -106,6 +102,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
                $this->addFieldsIf( 'ar_comment', $fld_comment || $fld_parsedcomment );
                $this->addFieldsIf( 'ar_minor_edit', $fld_minor );
                $this->addFieldsIf( 'ar_len', $fld_len );
+               $this->addFieldsIf( 'ar_sha1', $fld_sha1 );
 
                if ( $fld_content ) {
                        $this->addTables( 'text' );
@@ -183,7 +180,10 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
                        if ( $params['unique'] ) {
                                $this->addOption( 'GROUP BY', 'ar_title' );
                        } else {
-                               $this->addOption( 'ORDER BY', 'ar_title, ar_timestamp' );
+                               $this->addOption( 'ORDER BY', array(
+                                       'ar_title',
+                                       'ar_timestamp'
+                               ));
                        }
                } else {
                        if ( $mode == 'revs' ) {
@@ -238,6 +238,13 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
                        if ( $fld_len ) {
                                $rev['len'] = $row->ar_len;
                        }
+                       if ( $fld_sha1 ) {
+                               if ( $row->ar_sha1 != '' ) {
+                                       $rev['sha1'] = wfBaseConvert( $row->ar_sha1, 36, 16, 40 );
+                               } else {
+                                       $rev['sha1'] = '';
+                               }
+                       }
                        if ( $fld_content ) {
                                ApiResult::setContent( $rev, Revision::getRevisionText( $row ) );
                        }
@@ -319,6 +326,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
                                        'parsedcomment',
                                        'minor',
                                        'len',
+                                       'sha1',
                                        'content',
                                        'token'
                                ),
@@ -329,8 +337,8 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
 
        public function getParamDescription() {
                return array(
-                       'start' => 'The timestamp to start enumerating from (1,2)',
-                       'end' => 'The timestamp to stop enumerating at (1,2)',
+                       'start' => 'The timestamp to start enumerating from (1, 2)',
+                       'end' => 'The timestamp to stop enumerating at (1, 2)',
                        'dir' => $this->getDirectionDescription( $this->getModulePrefix(), ' (1, 3)' ),
                        'from' => 'Start listing at this title (3)',
                        'to' => 'Stop listing at this title (3)',
@@ -345,7 +353,8 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
                                ' comment        - Adds the comment of the revision',
                                ' parsedcomment  - Adds the parsed comment of the revision',
                                ' minor          - Tags if the revision is minor',
-                               ' len            - Adds the length of the revision',
+                               ' len            - Adds the length (bytes) of the revision',
+                               ' sha1           - Adds the SHA-1 (base 16) of the revision',
                                ' content        - Adds the content of the revision',
                                ' token          - Gives the edit token',
                        ),
@@ -387,19 +396,19 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
 
        public function getExamples() {
                return array(
-                       'List the last deleted revisions of Main Page and Talk:Main Page, with content (mode 1):',
-                       '  api.php?action=query&list=deletedrevs&titles=Main%20Page|Talk:Main%20Page&drprop=user|comment|content',
-                       'List the last 50 deleted contributions by Bob (mode 2):',
-                       '  api.php?action=query&list=deletedrevs&druser=Bob&drlimit=50',
-                       'List the first 50 deleted revisions in the main namespace (mode 3):',
-                       '  api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50',
-                       'List the first 50 deleted pages in the Talk namespace (mode 3):',
-                       '  api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50&drnamespace=1&drunique=',
+                       'api.php?action=query&list=deletedrevs&titles=Main%20Page|Talk:Main%20Page&drprop=user|comment|content'
+                               => 'List the last deleted revisions of Main Page and Talk:Main Page, with content (mode 1)',
+                       'api.php?action=query&list=deletedrevs&druser=Bob&drlimit=50'
+                               => 'List the last 50 deleted contributions by Bob (mode 2)',
+                       'api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50'
+                               => 'List the first 50 deleted revisions in the main namespace (mode 3)',
+                       'api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50&drnamespace=1&drunique='
+                               => 'List the first 50 deleted pages in the Talk namespace (mode 3):',
                );
        }
 
        public function getHelpUrls() {
-               return 'http://www.mediawiki.org/wiki/API:Deletedrevs';
+               return 'https://www.mediawiki.org/wiki/API:Deletedrevs';
        }
 
        public function getVersion() {