Deprecate $wgCommandLineMode

The global variable is now exactly the same as
`MW_ENTRY_POINT === 'cli'`.

Bug: T313841
Change-Id: I254bf4aa426e4834705be351cc9eb06d18a33f79
This commit is contained in:
Bartosz Dziewoński 2024-01-02 22:21:50 +01:00
parent 6876ccf177
commit b2c83a0721
7 changed files with 7 additions and 17 deletions

View file

@ -296,6 +296,8 @@ because of Phabricator reports.
bootstrap.integration.php and suite.xml. Run tests with `composer phpunit`
instead, or simply `vendor/bin/phpunit`, which use bootstrap.php and
phpunit.xml.dist.
* The global variable $wgCommandLineMode is deprecated. In most cases checks
for `$wgCommandLineMode` can be replaced with `MW_ENTRY_POINT === 'cli'`.
* User::isBlocked(), ::isBlockedFromCreateAccount() and ::isBlockedFrom() now
emit deprecation warnings. They were deprecated since 1.34, 1.37 and 1.33
respectively.

View file

@ -52,7 +52,7 @@ class LocalSettingsLoader {
}
// make available some non-config globals available
// phpcs:ignore MediaWiki.VariableAnalysis.UnusedGlobalVariables.UnusedGlobal$wgCommandLineMode
// phpcs:ignore MediaWiki.VariableAnalysis.UnusedGlobalVariables.UnusedGlobal$wgCommandLineMode, MediaWiki.Usage.DeprecatedGlobalVariables
global $wgCommandLineMode;
// make additional variables available

View file

@ -134,8 +134,9 @@ if ( !interface_exists( LoggerInterface::class ) ) {
trigger_error( $message, E_USER_ERROR );
}
// Set $wgCommandLineMode to false if it wasn't set to true.
$wgCommandLineMode ??= false;
// Deprecated global variable for backwards-compatibility.
// New code should check MW_ENTRY_POINT directly.
$wgCommandLineMode = MW_ENTRY_POINT === 'cli';
/**
* $wgConf hold the site configuration.

View file

@ -895,8 +895,6 @@ abstract class Maintenance {
if ( ob_get_level() ) {
ob_end_flush();
}
# Same with these
$overrides['CommandLineMode'] = true;
# Override $wgServer
if ( $this->hasOption( 'server' ) ) {

View file

@ -208,8 +208,6 @@ class MaintenanceRunner {
* not including the script itself.
*/
private function initInternal( string $script, array $scriptArgv ) {
global $wgCommandLineMode;
$this->script = $script;
$this->scriptArgv = $scriptArgv;
@ -223,8 +221,6 @@ class MaintenanceRunner {
// make sure we clean up after ourselves.
register_shutdown_function( [ $this, 'cleanup' ] );
$wgCommandLineMode = true;
// Turn off output buffering if it's on
while ( ob_get_level() > 0 ) {
ob_end_flush();
@ -541,7 +537,7 @@ class MaintenanceRunner {
* @return void
*/
public function defineSettings() {
global $wgCommandLineMode, $IP;
global $IP;
if ( $this->parameters->hasOption( 'conf' ) ) {
// Define the constant instead of directly setting $settingsFile
@ -586,7 +582,6 @@ class MaintenanceRunner {
}
$this->withoutLocalSettings = true;
}
$wgCommandLineMode = true;
}
/**

View file

@ -35,8 +35,6 @@ if ( getenv( 'MW_INSTALL_PATH' ) === false ) {
TestSetup::snapshotGlobals();
$GLOBALS['wgCommandLineMode'] = true;
// Start an output buffer to avoid headers being sent by constructors,
// data providers, etc. (T206476)
ob_start();

View file

@ -28,8 +28,6 @@ class PHPUnitMaintClass {
}
public function prepareEnvironment() {
global $wgCommandLineMode;
# Disable the memory limit as it's not needed for tests.
ini_set( 'memory_limit', -1 );
@ -38,8 +36,6 @@ class PHPUnitMaintClass {
# But sometimes this doesn't seem to be the case.
ini_set( 'max_execution_time', 0 );
$wgCommandLineMode = true;
# Turn off output buffering if it's on
while ( ob_get_level() > 0 ) {
ob_end_flush();