From: daniel Date: Thu, 13 Dec 2012 16:50:45 +0000 (+0100) Subject: (bug 42168) Nicely handle missing revisions in ApiQueryRevisions. X-Git-Tag: 1.31.0-rc.0~21245^2 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=e0ca64fb6c17022c14a40cd9f075f6ddb4b2934b;p=lhc%2Fweb%2Fwiklou.git (bug 42168) Nicely handle missing revisions in ApiQueryRevisions. ApiQueryRevisions had fatal errors when the Content object of a revision was null. Should be fixed now. Change-Id: Ic41d03fc55413ba7ba1c96b4f06d71d79fb7c4eb --- diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index 66ff3f09fb..cca7eb2c70 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -496,14 +496,14 @@ class ApiQueryRevisions extends ApiQueryBase { // Expand templates after getting section content because // template-added sections don't count and Parser::preprocess() // will have less input - if ( $this->section !== false ) { + if ( $content && $this->section !== false ) { $content = $content->getSection( $this->section, false ); if ( !$content ) { $this->dieUsage( "There is no section {$this->section} in r" . $revision->getId(), 'nosuchsection' ); } } } - if ( $this->fld_content && !$revision->isDeleted( Revision::DELETED_TEXT ) ) { + if ( $this->fld_content && $content && !$revision->isDeleted( Revision::DELETED_TEXT ) ) { $text = null; if ( $this->generateXML ) { @@ -567,13 +567,20 @@ class ApiQueryRevisions extends ApiQueryBase { ApiResult::setContent( $vals, $text ); } } elseif ( $this->fld_content ) { - $vals['texthidden'] = ''; + if ( $revision->isDeleted( Revision::DELETED_TEXT ) ) { + $vals['texthidden'] = ''; + } else { + $vals['textmissing'] = ''; + } } if ( !is_null( $this->diffto ) || !is_null( $this->difftotext ) ) { global $wgAPIMaxUncachedDiffs; static $n = 0; // Number of uncached diffs we've had - if ( $n < $wgAPIMaxUncachedDiffs ) { + + if ( is_null( $content ) ) { + $vals['textmissing'] = ''; + } elseif ( $n < $wgAPIMaxUncachedDiffs ) { $vals['diff'] = array(); $context = new DerivativeContext( $this->getContext() ); $context->setTitle( $title ); @@ -786,7 +793,8 @@ class ApiQueryRevisions extends ApiQueryBase { ApiBase::PROP_TYPE => 'string', ApiBase::PROP_NULLABLE => true ), - 'texthidden' => 'boolean' + 'texthidden' => 'boolean', + 'textmissing' => 'boolean', ), 'contentmodel' => array( 'contentmodel' => 'string'