r106876 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106875‎ | r106876 | r106877 >
Date:21:58, 20 December 2011
Author:aaron
Status:ok (Comments)
Tags:
Comment:
FU r106514: Sanity check for empty sha1 values in the DB
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryDeletedrevs.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryRevisions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryDeletedrevs.php
@@ -236,7 +236,11 @@
237237 $rev['len'] = $row->ar_len;
238238 }
239239 if ( $fld_sha1 ) {
240 - $rev['sha1'] = wfBaseConvert( $row->ar_sha1, 36, 16, 40 );
 240+ if ( $row->ar_sha1 != '' ) {
 241+ $rev['sha1'] = wfBaseConvert( $row->ar_sha1, 36, 16, 40 );
 242+ } else {
 243+ $rev['sha1'] = '';
 244+ }
241245 }
242246 if ( $fld_content ) {
243247 ApiResult::setContent( $rev, Revision::getRevisionText( $row ) );
Index: trunk/phase3/includes/api/ApiQueryRevisions.php
@@ -414,7 +414,11 @@
415415 }
416416
417417 if ( $this->fld_sha1 ) {
418 - $vals['sha1'] = wfBaseConvert( $revision->getSha1(), 36, 16, 40 );
 418+ if ( $revision->getSha1() != '' ) {
 419+ $vals['sha1'] = wfBaseConvert( $revision->getSha1(), 36, 16, 40 );
 420+ } else {
 421+ $vals['sha1'] = '';
 422+ }
419423 }
420424
421425 if ( $this->fld_comment || $this->fld_parsedcomment ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r106514Expose rev_sha1/ar_sha1 to API (bug 21860)aaron18:27, 17 December 2011

Comments

#Comment by Duplicatebug (talk | contribs)   20:41, 21 December 2011

I am not sure, it is better to give an emtpy value or give no value, because an empty value is often used as a boolean in the api (xml) output.

Status & tagging log