Disable filter by redirect Special:AllPages and query=allpages in miser mode
authorReedy <reedy@wikimedia.org>
Mon, 20 Mar 2017 17:54:40 +0000 (17:54 +0000)
committerAnomie <bjorsch@wikimedia.org>
Mon, 20 Mar 2017 19:15:59 +0000 (19:15 +0000)
Bug: T160916
Change-Id: Ib9562b404731e1f621b9f07c33821d04cd2aa6ae

RELEASE-NOTES-1.29
includes/api/ApiQueryAllPages.php
includes/specials/SpecialAllPages.php

index 0c483e9..b9a93f1 100644 (file)
@@ -80,6 +80,7 @@ production.
 * (T27187) Search suggestions based on jquery.suggestions will now correctly only
   highlight prefix matches in the results.
 * (T157035) "new mw.Uri()" was ignoring options when using default URI.
 * (T27187) Search suggestions based on jquery.suggestions will now correctly only
   highlight prefix matches in the results.
 * (T157035) "new mw.Uri()" was ignoring options when using default URI.
+* Special:Allpages can no longer be filtered by redirect in miser mode.
 
 === Action API changes in 1.29 ===
 * Submitting sensitive authentication request parameters to action=login,
 
 === Action API changes in 1.29 ===
 * Submitting sensitive authentication request parameters to action=login,
@@ -114,6 +115,9 @@ production.
 * action=purge now requires a POST.
 * There is a new `languagevariants` siprop for action=query&meta=siteinfo,
   which returns a list of languages with active LanguageConverter instances.
 * action=purge now requires a POST.
 * There is a new `languagevariants` siprop for action=query&meta=siteinfo,
   which returns a list of languages with active LanguageConverter instances.
+* action=query&query=allpages will no longer filter redirects using a database
+  query in miser mode. This may result in less results being returned than were
+  requested.
 
 === Action API internal changes in 1.29 ===
 * New methods were added to ApiBase to handle errors and warnings using i18n
 
 === Action API internal changes in 1.29 ===
 * New methods were added to ApiBase to handle errors and warnings using i18n
index 7460bd5..6b959ae 100644 (file)
@@ -76,10 +76,13 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
                        $this->addWhere( "page_title $op= $cont_from" );
                }
 
                        $this->addWhere( "page_title $op= $cont_from" );
                }
 
-               if ( $params['filterredir'] == 'redirects' ) {
-                       $this->addWhereFld( 'page_is_redirect', 1 );
-               } elseif ( $params['filterredir'] == 'nonredirects' ) {
-                       $this->addWhereFld( 'page_is_redirect', 0 );
+               $miserMode = $this->getConfig()->get( 'MiserMode' );
+               if ( !$miserMode ) {
+                       if ( $params['filterredir'] == 'redirects' ) {
+                               $this->addWhereFld( 'page_is_redirect', 1 );
+                       } elseif ( $params['filterredir'] == 'nonredirects' ) {
+                               $this->addWhereFld( 'page_is_redirect', 0 );
+                       }
                }
 
                $this->addWhereFld( 'page_namespace', $params['namespace'] );
                }
 
                $this->addWhereFld( 'page_namespace', $params['namespace'] );
@@ -108,6 +111,18 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
                        $selectFields = $resultPageSet->getPageTableFields();
                }
 
                        $selectFields = $resultPageSet->getPageTableFields();
                }
 
+               $miserModeFilterRedirValue = null;
+               $miserModeFilterRedir = $miserMode && $params['filterredir'] !== 'all';
+               if ( $miserModeFilterRedir ) {
+                       $selectFields[] = 'page_is_redirect';
+
+                       if ( $params['filterredir'] == 'redirects' ) {
+                               $miserModeFilterRedirValue = 1;
+                       } elseif ( $params['filterredir'] == 'nonredirects' ) {
+                               $miserModeFilterRedirValue = 0;
+                       }
+               }
+
                $this->addFields( $selectFields );
                $forceNameTitleIndex = true;
                if ( isset( $params['minsize'] ) ) {
                $this->addFields( $selectFields );
                $forceNameTitleIndex = true;
                if ( isset( $params['minsize'] ) ) {
@@ -219,6 +234,11 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
                                break;
                        }
 
                                break;
                        }
 
+                       if ( $miserModeFilterRedir && (int)$row->page_is_redirect !== $miserModeFilterRedirValue ) {
+                               // Filter implemented in PHP due to being in Miser Mode
+                               continue;
+                       }
+
                        if ( is_null( $resultPageSet ) ) {
                                $title = Title::makeTitle( $row->page_namespace, $row->page_title );
                                $vals = [
                        if ( is_null( $resultPageSet ) ) {
                                $title = Title::makeTitle( $row->page_namespace, $row->page_title );
                                $vals = [
@@ -242,7 +262,7 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
        }
 
        public function getAllowedParams() {
        }
 
        public function getAllowedParams() {
-               return [
+               $ret = [
                        'from' => null,
                        'continue' => [
                                ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
                        'from' => null,
                        'continue' => [
                                ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
@@ -314,6 +334,12 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
                                ApiBase::PARAM_DFLT => 'all'
                        ],
                ];
                                ApiBase::PARAM_DFLT => 'all'
                        ],
                ];
+
+               if ( $this->getConfig()->get( 'MiserMode' ) ) {
+                       $ret['filterredir'][ApiBase::PARAM_HELP_MSG_APPEND] = [ 'api-help-param-limited-in-miser-mode' ];
+               }
+
+               return $ret;
        }
 
        protected function getExamplesMessages() {
        }
 
        protected function getExamplesMessages() {
index 4b8446a..fd7bc3f 100644 (file)
@@ -69,7 +69,11 @@ class SpecialAllPages extends IncludableSpecialPage {
                $from = $request->getVal( 'from', null );
                $to = $request->getVal( 'to', null );
                $namespace = $request->getInt( 'namespace' );
                $from = $request->getVal( 'from', null );
                $to = $request->getVal( 'to', null );
                $namespace = $request->getInt( 'namespace' );
-               $hideredirects = $request->getBool( 'hideredirects', false );
+
+               $miserMode = (bool)$this->getConfig()->get( 'MiserMode' );
+
+               // Redirects filter is disabled in MiserMode
+               $hideredirects = $request->getBool( 'hideredirects', false ) && !$miserMode;
 
                $namespaces = $this->getLanguage()->getNamespaces();
 
 
                $namespaces = $this->getLanguage()->getNamespaces();
 
@@ -100,6 +104,7 @@ class SpecialAllPages extends IncludableSpecialPage {
        protected function outputHTMLForm( $namespace = NS_MAIN,
                $from = '', $to = '', $hideRedirects = false
        ) {
        protected function outputHTMLForm( $namespace = NS_MAIN,
                $from = '', $to = '', $hideRedirects = false
        ) {
+               $miserMode = (bool)$this->getConfig()->get( 'MiserMode' );
                $fields = [
                        'from' => [
                                'type' => 'text',
                $fields = [
                        'from' => [
                                'type' => 'text',
@@ -133,6 +138,11 @@ class SpecialAllPages extends IncludableSpecialPage {
                                'value' => $hideRedirects,
                        ],
                ];
                                'value' => $hideRedirects,
                        ],
                ];
+
+               if ( $miserMode ) {
+                       unset ( $fields['hideredirects'] );
+               }
+
                $form = HTMLForm::factory( 'table', $fields, $this->getContext() );
                $form->setMethod( 'get' )
                        ->setWrapperLegendMsg( 'allpages' )
                $form = HTMLForm::factory( 'table', $fields, $this->getContext() );
                $form->setMethod( 'get' )
                        ->setWrapperLegendMsg( 'allpages' )