Umherirrender has uploaded a new change for review.
https://gerrit.wikimedia.org/r/172021
Change subject: Refactor content fetch condition in ApiQueryRevisionBase
......................................................................
Refactor content fetch condition in ApiQueryRevisionBase
Use a member variable to make the ifs easier to maintenance.
Change-Id: I535740094708c563298a8b8d34027519d3900758
---
M includes/api/ApiQueryDeletedRevisions.php
M includes/api/ApiQueryRevisions.php
M includes/api/ApiQueryRevisionsBase.php
3 files changed, 8 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/21/172021/1
diff --git a/includes/api/ApiQueryDeletedRevisions.php
b/includes/api/ApiQueryDeletedRevisions.php
index 0271037..26ae266 100644
--- a/includes/api/ApiQueryDeletedRevisions.php
+++ b/includes/api/ApiQueryDeletedRevisions.php
@@ -94,7 +94,7 @@
$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
diff --git a/includes/api/ApiQueryRevisions.php
b/includes/api/ApiQueryRevisions.php
index 2e980f3..32355b9 100644
--- a/includes/api/ApiQueryRevisions.php
+++ b/includes/api/ApiQueryRevisions.php
@@ -167,7 +167,7 @@
$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 */
diff --git a/includes/api/ApiQueryRevisionsBase.php
b/includes/api/ApiQueryRevisionsBase.php
index 3879d7b..4d75a20 100644
--- a/includes/api/ApiQueryRevisionsBase.php
+++ b/includes/api/ApiQueryRevisionsBase.php
@@ -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 @@
$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 @@
$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()
--
To view, visit https://gerrit.wikimedia.org/r/172021
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I535740094708c563298a8b8d34027519d3900758
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits