From 7745d4a6105d32523c5c30f61f91edf565ae7125 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Mon, 28 Oct 2019 16:52:37 +0000 Subject: [PATCH] Require $wgLocaltimezone to be set Change-Id: I0e09d87152bf7694c8ada935d5c37c244d70cb69 --- extension.json | 1 + includes/DiscussionToolsHooks.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/extension.json b/extension.json index 04863ca69..acaa3cbc0 100644 --- a/extension.json +++ b/extension.json @@ -14,6 +14,7 @@ "MessagesDirs": { "DiscussionTools": [ "i18n" ] }, + "callback": "DiscussionToolsHooks::onRegistration", "ResourceFileModulePaths": { "localBasePath": "modules", "remoteExtPath": "DiscussionTools/modules" diff --git a/includes/DiscussionToolsHooks.php b/includes/DiscussionToolsHooks.php index a78c0a6df..ffa5d96c8 100644 --- a/includes/DiscussionToolsHooks.php +++ b/includes/DiscussionToolsHooks.php @@ -8,6 +8,21 @@ */ class DiscussionToolsHooks { + + public static function onRegistration() { + global $wgLocaltimezone; + // If $wgLocaltimezone isn't hard-coded, it is evaluated from the system + // timezone. On some systems this isn't guaranteed to be static, for example + // on Debian, GMT can get converted to UTC, instead of Europe/London. + // + // Timestamp parsing assumes that the timezone never changes. + // + // HACK: Do not run this test on CI as $wgLocaltimezone is not configured. + if ( !$wgLocaltimezone && !getenv( 'ZUUL_PROJECT' ) ) { + throw new \ConfigException( 'DiscussionTools requires $wgLocaltimezone to be set' ); + } + } + /** * Adds DiscussionTools JS to the output. *