Refactor content fetch condition in ApiQueryRevisionsBase
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 8 Nov 2014 10:25:33 +0000 (11:25 +0100)
committerumherirrender <umherirrender_de.wp@web.de>
Mon, 10 Nov 2014 17:50:36 +0000 (18:50 +0100)
Use a member variable to make the ifs easier to maintain.

Change-Id: I535740094708c563298a8b8d34027519d3900758

includes/api/ApiQueryAllDeletedRevisions.php
includes/api/ApiQueryDeletedRevisions.php
includes/api/ApiQueryRevisions.php
includes/api/ApiQueryRevisionsBase.php

index 0292e9a..0b1accb 100644 (file)
@@ -109,7 +109,7 @@ class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase {
                        $this->addWhereFld( 'ct_tag', $params['tag'] );
                }
 
-               if ( $this->fld_content || !is_null( $this->diffto ) || !is_null( $this->difftotext ) ) {
+               if ( $this->fetchContent ) {
                        // Modern MediaWiki has the content for deleted revs in the 'text'
                        // table using fields old_text and old_flags. But revisions deleted
                        // pre-1.5 store the content in the 'archive' table directly using
index 0271037..26ae266 100644 (file)
@@ -94,7 +94,7 @@ class ApiQueryDeletedRevisions extends ApiQueryRevisionsBase {
                        $this->addWhereFld( 'ct_tag', $params['tag'] );
                }
 
-               if ( $this->fld_content || !is_null( $this->diffto ) || !is_null( $this->difftotext ) ) {
+               if ( $this->fetchContent ) {
                        // Modern MediaWiki has the content for deleted revs in the 'text'
                        // table using fields old_text and old_flags. But revisions deleted
                        // pre-1.5 store the content in the 'archive' table directly using
index 2e980f3..32355b9 100644 (file)
@@ -167,7 +167,7 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase {
                        $this->addWhereFld( 'ct_tag', $params['tag'] );
                }
 
-               if ( $this->fld_content || !is_null( $this->diffto ) || !is_null( $this->difftotext ) ) {
+               if ( $this->fetchContent ) {
                        // For each page we will request, the user must have read rights for that page
                        $user = $this->getUser();
                        /** @var $title Title */
index 3879d7b..4d75a20 100644 (file)
@@ -32,7 +32,7 @@
 abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
 
        protected $limit, $diffto, $difftotext, $expandTemplates, $generateXML, $section,
-               $parseContent, $contentFormat, $setParsedLimit = true;
+               $parseContent, $fetchContent, $contentFormat, $setParsedLimit = true;
 
        protected $fld_ids = false, $fld_flags = false, $fld_timestamp = false,
                $fld_size = false, $fld_sha1 = false, $fld_comment = false,
@@ -111,8 +111,11 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
 
                $this->limit = $params['limit'];
 
+               $this->fetchContent = $this->fld_content || !is_null( $this->diffto )
+                       || !is_null( $this->difftotext );
+
                $smallLimit = false;
-               if ( $this->fld_content || !is_null( $this->diffto ) || !is_null( $this->difftotext ) ) {
+               if ( $this->fetchContent ) {
                        $smallLimit = true;
                        $this->expandTemplates = $params['expandtemplates'];
                        $this->generateXML = $params['generatexml'];
@@ -249,7 +252,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
 
                $content = null;
                global $wgParser;
-               if ( $this->fld_content || !is_null( $this->diffto ) || !is_null( $this->difftotext ) ) {
+               if ( $this->fetchContent ) {
                        $content = $revision->getContent( Revision::FOR_THIS_USER, $this->getUser() );
                        // Expand templates after getting section content because
                        // template-added sections don't count and Parser::preprocess()