Add a run mode to $wgDisableQueryPageUpdate
authorUmherirrender <umherirrender_de.wp@web.de>
Mon, 19 Aug 2019 14:49:43 +0000 (16:49 +0200)
committerJforrester <jforrester@wikimedia.org>
Thu, 26 Sep 2019 22:33:53 +0000 (22:33 +0000)
The run mode is used to show a different message on the special page,
instead of the current one "Updates for this page are currently
disabled. Data here will not presently be refreshed." even the data gets
updated with a different cron job.

Bug: T78711
Change-Id: Ib63d16bfea477dec43323b39671cc068530e2f0b

includes/DefaultSettings.php
includes/specialpage/QueryPage.php
languages/i18n/en.json
languages/i18n/qqq.json
maintenance/updateSpecialPages.php

index 29b628c..31cb7ae 100644 (file)
@@ -7937,6 +7937,7 @@ $wgAllowSpecialInclusion = true;
 /**
  * Set this to an array of special page names to prevent
  * maintenance/updateSpecialPages.php from updating those pages.
+ * Mapping each special page name to an run mode like 'periodical' if a cronjob is set up.
  */
 $wgDisableQueryPageUpdate = false;
 
index b7eb3c0..6ed5e12 100644 (file)
@@ -118,6 +118,30 @@ abstract class QueryPage extends SpecialPage {
                return $qp;
        }
 
+       /**
+        * Get a list of query pages disabled and with it's run mode
+        * @param Config $config
+        * @return string[]
+        */
+       public static function getDisabledQueryPages( Config $config ) {
+               $disableQueryPageUpdate = $config->get( 'DisableQueryPageUpdate' );
+
+               if ( !is_array( $disableQueryPageUpdate ) ) {
+                       return [];
+               }
+
+               $pages = [];
+               foreach ( $disableQueryPageUpdate as $name => $runMode ) {
+                       if ( is_int( $name ) ) {
+                               // The run mode may be omitted
+                               $pages[$runMode] = 'disabled';
+                       } else {
+                               $pages[$name] = $runMode;
+                       }
+               }
+               return $pages;
+       }
+
        /**
         * A mutator for $this->listoutput;
         *
@@ -632,13 +656,21 @@ abstract class QueryPage extends SpecialPage {
 
                                # If updates on this page have been disabled, let the user know
                                # that the data set won't be refreshed for now
-                               if ( is_array( $this->getConfig()->get( 'DisableQueryPageUpdate' ) )
-                                       && in_array( $this->getName(), $this->getConfig()->get( 'DisableQueryPageUpdate' ) )
-                               ) {
-                                       $out->wrapWikiMsg(
-                                               "<div class=\"mw-querypage-no-updates\">\n$1\n</div>",
-                                               'querypage-no-updates'
-                                       );
+                               $disabledQueryPages = self::getDisabledQueryPages( $this->getConfig() );
+                               if ( isset( $disabledQueryPages[$this->getName()] ) ) {
+                                       $runMode = $disabledQueryPages[$this->getName()];
+                                       if ( $runMode === 'disabled' ) {
+                                               $out->wrapWikiMsg(
+                                                       "<div class=\"mw-querypage-no-updates\">\n$1\n</div>",
+                                                       'querypage-no-updates'
+                                               );
+                                       } else {
+                                               // Messages used here: querypage-updates-periodical
+                                               $out->wrapWikiMsg(
+                                                       "<div class=\"mw-querypage-updates-" . $runMode . "\">\n$1\n</div>",
+                                                       'querypage-updates-' . $runMode
+                                               );
+                                       }
                                }
                        }
                }
index 7944a37..8092bf6 100644 (file)
        "perfcached": "The following data is cached and may not be up to date. A maximum of {{PLURAL:$1|one result is|$1 results are}} available in the cache.",
        "perfcachedts": "The following data is cached, and was last updated $1. A maximum of {{PLURAL:$4|one result is|$4 results are}} available in the cache.",
        "querypage-no-updates": "Updates for this page are currently disabled.\nData here will not presently be refreshed.",
+       "querypage-updates-periodical": "Updates for this page are run periodically.",
        "viewsource": "View source",
        "viewsource-title": "View source for $1",
        "actionthrottled": "Action throttled",
index afbfd94..6b141f9 100644 (file)
        "perfcached": "Like {{msg-mw|perfcachedts}} but used when we do not know how long ago page was cached (unlikely to happen).\n\nParameters:\n* $1 - the max result cut off ($wgQueryCacheLimit)",
        "perfcachedts": "Used on pages that list page lists for which the displayed data is cached. Parameters:\n* $1 - a time stamp (date and time combined)\n* $2 - a date (optional)\n* $3 - a time (optional)\n* $4 - the cut off limit for cached results ($wgQueryCacheLimit). If there are more then this many results for the query, only the first $4 of those will be listed on the page. Usually $4 is about 1000.",
        "querypage-no-updates": "Text on some special pages, e.g. [[Special:FewestRevisions]].",
+       "querypage-updates-periodical": "Text on some special pages which are configurated with a periodical run of a maintenance script.\n\nSee also {{msg-mw|querypage-no-updates}}.",
        "viewsource": "The text displayed in place of the {{msg-mw|Edit}} tab when the user has no permission to edit the page.\n\nSee also:\n* {{msg-mw|Viewsource}}\n* {{msg-mw|Accesskey-ca-viewsource}}\n* {{msg-mw|Tooltip-ca-viewsource}}\n{{Identical|View source}}",
        "viewsource-title": "Page title shown when trying to edit a protected page. Parameters:\n* $1 - the name of the page",
        "actionthrottled": "This is the title of an error page. Read it in combination with {{msg-mw|actionthrottledtext}}.",
index 5d756e8..7e57f67 100644 (file)
@@ -42,12 +42,13 @@ class UpdateSpecialPages extends Maintenance {
        }
 
        public function execute() {
-               global $wgQueryCacheLimit, $wgDisableQueryPageUpdate;
+               global $wgQueryCacheLimit;
 
                $dbw = $this->getDB( DB_MASTER );
 
                $this->doSpecialPageCacheUpdates( $dbw );
 
+               $disabledQueryPages = QueryPage::getDisabledQueryPages( $this->getConfig() );
                foreach ( QueryPage::getPages() as $page ) {
                        list( , $special ) = $page;
                        $limit = $page[2] ?? null;
@@ -59,7 +60,7 @@ class UpdateSpecialPages extends Maintenance {
                        }
 
                        if ( !$this->hasOption( 'override' )
-                               && $wgDisableQueryPageUpdate && in_array( $special, $wgDisableQueryPageUpdate )
+                               && isset( $disabledQueryPages[$special] )
                        ) {
                                $this->output( sprintf( "%-30s [QueryPage] disabled\n", $special ) );
                                continue;