Merge "objectcache: Add comments about DB isolation to WANObjectCache"
[lhc/web/wiklou.git] / includes / api / ApiQueryRevisionsBase.php
index 1805f40..d57dc3c 100644 (file)
@@ -37,7 +37,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
        protected $fld_ids = false, $fld_flags = false, $fld_timestamp = false,
                $fld_size = false, $fld_sha1 = false, $fld_comment = false,
                $fld_parsedcomment = false, $fld_user = false, $fld_userid = false,
-               $fld_content = false, $fld_tags = false, $fld_contentmodel = false;
+               $fld_content = false, $fld_tags = false, $fld_contentmodel = false, $fld_parsetree = false;
 
        public function execute() {
                $this->run();
@@ -104,6 +104,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
                $this->fld_userid = isset( $prop['userid'] );
                $this->fld_user = isset( $prop['user'] );
                $this->fld_tags = isset( $prop['tags'] );
+               $this->fld_parsetree = isset( $prop['parsetree'] );
 
                if ( !empty( $params['contentformat'] ) ) {
                        $this->contentFormat = $params['contentformat'];
@@ -112,7 +113,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
                $this->limit = $params['limit'];
 
                $this->fetchContent = $this->fld_content || !is_null( $this->diffto )
-                       || !is_null( $this->difftotext );
+                       || !is_null( $this->difftotext ) || $this->fld_parsetree;
 
                $smallLimit = false;
                if ( $this->fetchContent ) {
@@ -168,13 +169,13 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
                        }
                }
 
-               if ( $this->fld_flags && $revision->isMinor() ) {
-                       $vals['minor'] = '';
+               if ( $this->fld_flags ) {
+                       $vals['minor'] = $revision->isMinor();
                }
 
                if ( $this->fld_user || $this->fld_userid ) {
                        if ( $revision->isDeleted( Revision::DELETED_USER ) ) {
-                               $vals['userhidden'] = '';
+                               $vals['userhidden'] = true;
                                $anyHidden = true;
                        }
                        if ( $revision->userCan( Revision::DELETED_USER, $user ) ) {
@@ -183,7 +184,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
                                }
                                $userid = $revision->getUser( Revision::RAW );
                                if ( !$userid ) {
-                                       $vals['anon'] = '';
+                                       $vals['anon'] = true;
                                }
 
                                if ( $this->fld_userid ) {
@@ -206,7 +207,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
 
                if ( $this->fld_sha1 ) {
                        if ( $revision->isDeleted( Revision::DELETED_TEXT ) ) {
-                               $vals['sha1hidden'] = '';
+                               $vals['sha1hidden'] = true;
                                $anyHidden = true;
                        }
                        if ( $revision->userCan( Revision::DELETED_TEXT, $user ) ) {
@@ -224,7 +225,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
 
                if ( $this->fld_comment || $this->fld_parsedcomment ) {
                        if ( $revision->isDeleted( Revision::DELETED_COMMENT ) ) {
-                               $vals['commenthidden'] = '';
+                               $vals['commenthidden'] = true;
                                $anyHidden = true;
                        }
                        if ( $revision->userCan( Revision::DELETED_COMMENT, $user ) ) {
@@ -267,16 +268,17 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
                                }
                        }
                        if ( $revision->isDeleted( Revision::DELETED_TEXT ) ) {
-                               $vals['texthidden'] = '';
+                               $vals['texthidden'] = true;
                                $anyHidden = true;
                        } elseif ( !$content ) {
-                               $vals['textmissing'] = '';
+                               $vals['textmissing'] = true;
                        }
                }
-               if ( $this->fld_content && $content ) {
-                       $text = null;
-
-                       if ( $this->generateXML ) {
+               if ( $this->fld_parsetree || ( $this->fld_content && $this->generateXML ) ) {
+                       if ( !$this->fld_parsetree ) {
+                               $this->logFeatureUsage( 'action=query&prop=revisions+base&generatexml' );
+                       }
+                       if ( $content ) {
                                if ( $content->getModel() === CONTENT_MODEL_WIKITEXT ) {
                                        $t = $content->getNativeData(); # note: don't set $text
 
@@ -293,12 +295,16 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
                                        }
                                        $vals['parsetree'] = $xml;
                                } else {
-                                       $vals['badcontentformatforparsetree'] = '';
+                                       $vals['badcontentformatforparsetree'] = true;
                                        $this->setWarning( "Conversion to XML is supported for wikitext only, " .
                                                $title->getPrefixedDBkey() .
                                                " uses content model " . $content->getModel() );
                                }
                        }
+               }
+
+               if ( $this->fld_content && $content ) {
+                       $text = null;
 
                        if ( $this->expandTemplates && !$this->parseContent ) {
                                #XXX: implement template expansion for all content types in ContentHandler?
@@ -314,7 +320,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
                                        $this->setWarning( "Template expansion is supported for wikitext only, " .
                                                $title->getPrefixedDBkey() .
                                                " uses content model " . $content->getModel() );
-                                       $vals['badcontentformat'] = '';
+                                       $vals['badcontentformat'] = true;
                                        $text = false;
                                }
                        }
@@ -335,7 +341,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
                                        $name = $title->getPrefixedDBkey();
                                        $this->setWarning( "The requested format {$this->contentFormat} is not " .
                                                "supported for content model $model used by $name" );
-                                       $vals['badcontentformat'] = '';
+                                       $vals['badcontentformat'] = true;
                                        $text = false;
                                } else {
                                        $text = $content->serialize( $format );
@@ -369,7 +375,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
                                                $name = $title->getPrefixedDBkey();
                                                $this->setWarning( "The requested format {$this->contentFormat} is not " .
                                                        "supported for content model $model used by $name" );
-                                               $vals['diff']['badcontentformat'] = '';
+                                               $vals['diff']['badcontentformat'] = true;
                                                $engine = null;
                                        } else {
                                                $difftocontent = ContentHandler::makeContent(
@@ -395,12 +401,12 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
                                        }
                                }
                        } else {
-                               $vals['diff']['notcached'] = '';
+                               $vals['diff']['notcached'] = true;
                        }
                }
 
                if ( $anyHidden && $revision->isDeleted( Revision::DELETED_RESTRICTED ) ) {
-                       $vals['suppressed'] = '';
+                       $vals['suppressed'] = true;
                }
 
                return $vals;
@@ -431,9 +437,26 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
                                        'comment',
                                        'parsedcomment',
                                        'content',
-                                       'tags'
+                                       'tags',
+                                       'parsetree',
                                ),
                                ApiBase::PARAM_HELP_MSG => 'apihelp-query+revisions+base-param-prop',
+                               ApiBase::PARAM_HELP_MSG_PER_VALUE => array(
+                                       'ids' => 'apihelp-query+revisions+base-paramvalue-prop-ids',
+                                       'flags' => 'apihelp-query+revisions+base-paramvalue-prop-flags',
+                                       'timestamp' => 'apihelp-query+revisions+base-paramvalue-prop-timestamp',
+                                       'user' => 'apihelp-query+revisions+base-paramvalue-prop-user',
+                                       'userid' => 'apihelp-query+revisions+base-paramvalue-prop-userid',
+                                       'size' => 'apihelp-query+revisions+base-paramvalue-prop-size',
+                                       'sha1' => 'apihelp-query+revisions+base-paramvalue-prop-sha1',
+                                       'contentmodel' => 'apihelp-query+revisions+base-paramvalue-prop-contentmodel',
+                                       'comment' => 'apihelp-query+revisions+base-paramvalue-prop-comment',
+                                       'parsedcomment' => 'apihelp-query+revisions+base-paramvalue-prop-parsedcomment',
+                                       'content' => 'apihelp-query+revisions+base-paramvalue-prop-content',
+                                       'tags' => 'apihelp-query+revisions+base-paramvalue-prop-tags',
+                                       'parsetree' => array( 'apihelp-query+revisions+base-paramvalue-prop-parsetree',
+                                               CONTENT_MODEL_WIKITEXT ),
+                               ),
                        ),
                        'limit' => array(
                                ApiBase::PARAM_TYPE => 'limit',
@@ -448,6 +471,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
                        ),
                        'generatexml' => array(
                                ApiBase::PARAM_DFLT => false,
+                               ApiBase::PARAM_DEPRECATED => true,
                                ApiBase::PARAM_HELP_MSG => 'apihelp-query+revisions+base-param-generatexml',
                        ),
                        'parse' => array(