Merge "MultiUsernameFilter: Don't try to split ids if they're not a string"
[mediawiki.git] / maintenance / run.php
blob1572bc84bd8ff9f76cb617b2edbbe3df065e8f0a
1 <?php
3 /**
4 * Entry point for running maintenance scripts.
6 * @file
7 * @ingroup Maintenance
8 */
10 use MediaWiki\Maintenance\MaintenanceRunner;
11 use MediaWiki\Settings\SettingsBuilder;
13 // No AutoLoader yet
14 require_once __DIR__ . '/Maintenance.php';
15 require_once __DIR__ . '/includes/MaintenanceRunner.php';
16 require_once __DIR__ . '/includes/MaintenanceParameters.php';
18 // Not in file scope, abort!
19 if ( !MaintenanceRunner::shouldExecute() ) {
20 return;
23 // Define the MediaWiki entrypoint
24 define( 'MEDIAWIKI', true );
26 $IP = wfDetectInstallPath();
27 require_once "$IP/includes/AutoLoader.php";
29 // phpcs:disable: MediaWiki.NamingConventions.ValidGlobalName.allowedPrefix
30 $runner = new MaintenanceRunner();
31 $runner->initFromWrapper( $argv );
33 $runner->defineSettings();
35 // Custom setup for Maintenance entry point
36 if ( !defined( 'MW_FINAL_SETUP_CALLBACK' ) ) {
38 // Define a function, since we can't put a closure or object
39 // reference into MW_FINAL_SETUP_CALLBACK.
40 function wfMaintenanceRunSetup( SettingsBuilder $settingsBuilder ) {
41 global $runner;
42 $runner->setup( $settingsBuilder );
45 define( 'MW_FINAL_SETUP_CALLBACK', 'wfMaintenanceRunSetup' );
48 // Initialize MediaWiki (load settings, extensions, etc).
49 require_once "$IP/includes/Setup.php";
51 $success = $runner->run();
53 // Exit with an error status if execute() returned false
54 if ( !$success ) {
55 exit( 1 );