wiki.techinc.nl/maintenance/run.php
Kevin Israel 63e07eed60 MaintenanceRunner: load script file early if possible
If possible, load the script file before running Setup.php. This way,
script files can control the setup process by defining constants. This
is needed by scome scripts, namely:
- instal.php, to override config loading by defining MW_CONFIG_CALLBACK
- generateConfigSchema.php, for setting MW_USE_CONFIG_SCHEMA_CLASS
- mergeMessageFileList.php, for setting MW_NO_EXTENSION_MESSAGES
- shell.php, for setting MW_NO_SESSION

Note that this will not work for scripts defined in extensions.

In order to allow script files to be loaded based on class name,
AutoLoader.php is included before Setup.php is run.

This is a modified version of I638f99c3cc6f8ab8216bd65ada959a6a11ff454b.

Co-authored-by: PleaseStand <pleasestand@live.com>
Change-Id: I2bf3b91c0a7162413cd1392252cb4f29a0d3d594
2023-03-14 10:18:29 +01:00

56 lines
1.3 KiB
PHP

<?php
/**
* Entry point for running maintenance scripts.
*
* @file
* @ingroup Maintenance
*/
use MediaWiki\Maintenance\MaintenanceRunner;
use MediaWiki\Settings\SettingsBuilder;
// No AutoLoader yet
require_once __DIR__ . '/Maintenance.php';
require_once __DIR__ . '/includes/MaintenanceRunner.php';
require_once __DIR__ . '/includes/MaintenanceParameters.php';
// Not in file scope, abort!
if ( !MaintenanceRunner::shouldExecute() ) {
return;
}
// Define the MediaWiki entrypoint
define( 'MEDIAWIKI', true );
$IP = wfDetectInstallPath();
require_once "$IP/includes/AutoLoader.php";
// phpcs:disable: MediaWiki.NamingConventions.ValidGlobalName.allowedPrefix
$runner = new MaintenanceRunner();
$runner->initFromWrapper( $argv );
$runner->defineSettings();
// Custom setup for Maintenance entry point
if ( !defined( 'MW_FINAL_SETUP_CALLBACK' ) ) {
// Define a function, since we can't put a closure or object
// reference into MW_FINAL_SETUP_CALLBACK.
function wfMaintenanceRunSetup( SettingsBuilder $settingsBuilder ) {
global $runner;
$runner->setup( $settingsBuilder );
}
define( 'MW_FINAL_SETUP_CALLBACK', 'wfMaintenanceRunSetup' );
}
// Initialize MediaWiki (load settings, extensions, etc).
require_once "$IP/includes/Setup.php";
$success = $runner->run();
// Exit with an error status if execute() returned false
if ( !$success ) {
exit( 1 );
}