From 21ee783cbe5dc2f49a051ffb1466799888964c5a Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 17 Dec 2011 18:27:38 +0000 Subject: [PATCH] Expose rev_sha1/ar_sha1 to API (bug 21860) --- includes/api/ApiQueryDeletedrevs.php | 9 ++++++++- includes/api/ApiQueryRevisions.php | 13 ++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/includes/api/ApiQueryDeletedrevs.php b/includes/api/ApiQueryDeletedrevs.php index 43e871f03b..8f286ceee4 100644 --- a/includes/api/ApiQueryDeletedrevs.php +++ b/includes/api/ApiQueryDeletedrevs.php @@ -53,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'] ); @@ -101,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' ); @@ -233,6 +235,9 @@ class ApiQueryDeletedrevs extends ApiQueryBase { if ( $fld_len ) { $rev['len'] = $row->ar_len; } + if ( $fld_sha1 ) { + $rev['sha1'] = $row->ar_sha1; + } if ( $fld_content ) { ApiResult::setContent( $rev, Revision::getRevisionText( $row ) ); } @@ -314,6 +319,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase { 'parsedcomment', 'minor', 'len', + 'sha1', 'content', 'token' ), @@ -340,7 +346,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 36) of the revision', ' content - Adds the content of the revision', ' token - Gives the edit token', ), diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index 7323d29b57..33ffaa131a 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -154,6 +154,7 @@ class ApiQueryRevisions extends ApiQueryBase { $this->fld_comment = isset ( $prop['comment'] ); $this->fld_parsedcomment = isset ( $prop['parsedcomment'] ); $this->fld_size = isset ( $prop['size'] ); + $this->fld_sha1 = isset ( $prop['sha1'] ); $this->fld_userid = isset( $prop['userid'] ); $this->fld_user = isset ( $prop['user'] ); $this->token = $params['token']; @@ -412,6 +413,14 @@ class ApiQueryRevisions extends ApiQueryBase { } } + if ( $this->fld_sha1 ) { + if ( !is_null( $revision->getSha1() ) ) { + $vals['sha1'] = $revision->getSha1(); + } else { + $vals['sha1'] = ''; + } + } + if ( $this->fld_comment || $this->fld_parsedcomment ) { if ( $revision->isDeleted( Revision::DELETED_COMMENT ) ) { $vals['commenthidden'] = ''; @@ -537,6 +546,7 @@ class ApiQueryRevisions extends ApiQueryBase { 'user', 'userid', 'size', + 'sha1', 'comment', 'parsedcomment', 'content', @@ -599,7 +609,8 @@ class ApiQueryRevisions extends ApiQueryBase { ' timestamp - The timestamp of the revision', ' user - User that made the revision', ' userid - User id of revision creator', - ' size - Length of the revision', + ' size - Length (bytes) of the revision', + ' sha1 - SHA-1 (base 36) the revision', ' comment - Comment by the user for revision', ' parsedcomment - Parsed comment by the user for the revision', ' content - Text of the revision', -- 2.20.1