Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
RegistrationHooks | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 1 |
onRegistration | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
30 |
1 | <?php |
2 | /** |
3 | * DiscussionTools tag hooks |
4 | * |
5 | * @file |
6 | * @ingroup Extensions |
7 | * @license MIT |
8 | */ |
9 | |
10 | namespace MediaWiki\Extension\DiscussionTools\Hooks; |
11 | |
12 | use MediaWiki\Config\ConfigException; |
13 | |
14 | class RegistrationHooks { |
15 | public static function onRegistration(): void { |
16 | // Use globals instead of Config. Accessing it so early blows up unrelated extensions (T255704). |
17 | global $wgLocaltimezone, $wgFragmentMode; |
18 | // HACK: Do not run these tests on CI as the globals are not configured. |
19 | if ( getenv( 'ZUUL_PROJECT' ) ) { |
20 | return; |
21 | } |
22 | // If $wgLocaltimezone isn't hard-coded, it is evaluated from the system |
23 | // timezone. On some systems this isn't guaranteed to be static, for example |
24 | // on Debian, GMT can get converted to UTC, instead of Europe/London. |
25 | // Timestamp parsing assumes that the timezone never changes. |
26 | if ( !$wgLocaltimezone ) { |
27 | throw new ConfigException( 'DiscussionTools requires $wgLocaltimezone to be set' ); |
28 | } |
29 | // If $wgFragmentMode is set to use 'legacy' encoding, determining the IDs of our thread |
30 | // headings is harder, especially since the implementation is different in Parsoid. |
31 | if ( !isset( $wgFragmentMode[0] ) || $wgFragmentMode[0] !== 'html5' ) { |
32 | throw new ConfigException( 'DiscussionTools requires $wgFragmentMode to be set to ' . |
33 | "[ 'html5', 'legacy' ] or [ 'html5' ]" ); |
34 | } |
35 | } |
36 | } |