From 9a8a33bd0f18272ef8e865c96c89cc5785ff5c2c Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Mon, 19 Aug 2019 16:49:43 +0200 Subject: [PATCH] Add a run mode to $wgDisableQueryPageUpdate 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 | 1 + includes/specialpage/QueryPage.php | 46 +++++++++++++++++++++++++----- languages/i18n/en.json | 1 + languages/i18n/qqq.json | 1 + maintenance/updateSpecialPages.php | 5 ++-- 5 files changed, 45 insertions(+), 9 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 29b628cd40..31cb7ae37c 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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; diff --git a/includes/specialpage/QueryPage.php b/includes/specialpage/QueryPage.php index b7eb3c0764..6ed5e125f0 100644 --- a/includes/specialpage/QueryPage.php +++ b/includes/specialpage/QueryPage.php @@ -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( - "
\n$1\n
", - 'querypage-no-updates' - ); + $disabledQueryPages = self::getDisabledQueryPages( $this->getConfig() ); + if ( isset( $disabledQueryPages[$this->getName()] ) ) { + $runMode = $disabledQueryPages[$this->getName()]; + if ( $runMode === 'disabled' ) { + $out->wrapWikiMsg( + "
\n$1\n
", + 'querypage-no-updates' + ); + } else { + // Messages used here: querypage-updates-periodical + $out->wrapWikiMsg( + "
\n$1\n
", + 'querypage-updates-' . $runMode + ); + } } } } diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 7944a374f8..8092bf6b3d 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -353,6 +353,7 @@ "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", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index afbfd94bab..6b141f909e 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -563,6 +563,7 @@ "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}}.", diff --git a/maintenance/updateSpecialPages.php b/maintenance/updateSpecialPages.php index 5d756e87a5..7e57f672b4 100644 --- a/maintenance/updateSpecialPages.php +++ b/maintenance/updateSpecialPages.php @@ -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; -- 2.20.1