phpunit: Remove $wgWikimediaJenkinsCI hack

This was added a few weeks ago in change b8f8bcc63f (I49123a5021)
to fix various PHPUnit tests (e.g. CentralAuth, T341731) that failed
due to $wgWikimediaJenkinsCI no longer being set during Setup.php
(and thus the `onRegistration` callbacks in extensions).

This in turn was caused by change d2a30096f (I95a80c44f8d88) which
changed the way tests load LocalSettings.php (no longer in the global
scope), which is why Quibble's LocalSettings.php file, which sets
$wgWikimediaJenkinsCI wasn't taking effect as global variable.

Due to this and other shortcomings with $wgWikimediaJenkinsCI, Quibble
introduced the MW_QUIBBLE_CI env variable. That has the benefit of
always  being available, even 1) without relying on a file being in
the global scope, 2) before Setup.php or LocalSettings apply, and
3) in contexts where these will never apply, such as  "pure" phpunit
tests that run via `composer phpunit:unit` which don't load
LocalSettings.php at all (which helps address T331621).

This core patch depends on patches that fix current usage in
Wikimedia Gerrit hosted extensions.

Bug: T90875
Depends-On: I996f673add2e8d6e07e20154a90f23eb858ced6b
Depends-On: I0a7470277cdd6939fe3e6e3df92f4d812d320b9c
Depends-On: I25acee1e6e88ca745435cbfa0b398041f04c94d6
Depends-On: I576946230022e9d3518e2ace9ea6f8f1211fcdbe
Change-Id: Ia4df6350f849ca278efef98678850e8c5562f338
This commit is contained in:
Timo Tijhof 2023-08-16 00:37:36 +01:00 committed by daniel
parent 83432c36db
commit c41bc51bbf

View file

@ -165,7 +165,6 @@ class TestSetup {
'_' => true,
'ignore' => true,
'wgAutoloadClasses' => true,
'wgWikimediaJenkinsCI' => true,
];
// Import $GLOBALS into local scope for the file.
@ -176,16 +175,11 @@ class TestSetup {
global $$key;
}
// phpcs:disable MediaWiki.VariableAnalysis.UnusedGlobalVariables
// Setup.php creates this variable, but we cannot wait for the below code to make it global,
// because Setup.php (and MW_SETUP_CALLBACK -> TestsAutoLoader.php) needs this to be a
// global during its execution (not just after).
// phpcs:ignore MediaWiki.VariableAnalysis.UnusedGlobalVariables
global $wgAutoloadClasses;
// $wgWikimediaJenkinsCI is not a config variable and is therefore not made explicitly global
// in Setup.php when checking wgScopeTest. Do that here instead, as the variable might be
// read in an extension before the code below is executed (T341731).
global $wgWikimediaJenkinsCI;
// phpcs:enable MediaWiki.VariableAnalysis.UnusedGlobalVariables
require_once $fileName;