mediawiki-extensions-Discus.../includes/Hooks/RegistrationHooks.php
libraryupgrader b0884b177c build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0

npm:
* postcss: 7.0.35 → 7.0.36
  * https://npmjs.com/advisories/1693 (CVE-2021-23368)
* glob-parent: 5.1.1 → 5.1.2
  * https://npmjs.com/advisories/1751 (CVE-2020-28469)
* trim-newlines: 3.0.0 → 3.0.1
  * https://npmjs.com/advisories/1753 (CVE-2021-33623)

Change-Id: I7a71e23da561599da417db3b3077b78d91173bbc
2021-07-22 16:29:04 +00:00

37 lines
1.3 KiB
PHP

<?php
/**
* DiscussionTools tag hooks
*
* @file
* @ingroup Extensions
* @license MIT
*/
namespace MediaWiki\Extension\DiscussionTools\Hooks;
use ConfigException;
class RegistrationHooks {
public static function onRegistration(): void {
// Use globals instead of Config. Accessing it so early blows up unrelated extensions (T255704).
global $wgLocaltimezone, $wgFragmentMode;
// HACK: Do not run these tests on CI as the globals are not configured.
if ( getenv( 'ZUUL_PROJECT' ) ) {
return;
}
// 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.
if ( !$wgLocaltimezone ) {
throw new ConfigException( 'DiscussionTools requires $wgLocaltimezone to be set' );
}
// If $wgFragmentMode is set to use 'legacy' encoding, determining the IDs of our thread
// headings is harder, especially since the implementation is different in Parsoid.
if ( !isset( $wgFragmentMode[0] ) || $wgFragmentMode[0] !== 'html5' ) {
throw new ConfigException( 'DiscussionTools requires $wgFragmentMode to be set to ' .
"[ 'html5', 'legacy' ] or [ 'html5' ]" );
}
}
}