2009-08-02 19:35:17 +00:00
|
|
|
<?php
|
2009-12-12 22:22:26 +00:00
|
|
|
/**
|
2010-12-16 19:15:12 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
2009-12-12 22:22:26 +00:00
|
|
|
* @file
|
|
|
|
|
* @ingroup Maintenance
|
|
|
|
|
* @defgroup Maintenance Maintenance
|
|
|
|
|
*/
|
|
|
|
|
|
Make sure RUN_MAINTENANCE_IF_MAIN is defined in tests.
This moves the definition of the RUN_MAINTENANCE_IF_MAIN constant
in Maintenance.php before the check on MEDIAWIKI, so the constant will
be defined even if MEDIAWIKI is also defined. This allows maintenance
scripts to be successfully loaded in a context in which MEDIAWIKI is
already defined, but RUN_MAINTENANCE_IF_MAIN is not. Without this
change, such an attempt would fail with a warning that the constant is
undefined at the bottom of the maintenance script.
A notable use case for loading a maintenance script inline is calling
RunJobs in a test case. This would work fine if the test is called via
MediaWiki's phpunit wrapper, since that wrapper is itself written as a
maintenance script, and thus declared RUN_MAINTENANCE_IF_MAIN.
However, integration tests may also be invoked without the wrapper,
using the phpunit.xml.dist config file instead. This is the standard way
to invoke PHPUnit from within an IDE like PhpStorm, allowing for debugging
of unit tests.
So, without this patch, integration tests that call RunJobs fail due to
an undeclared constant when run via IDE integration. With this patch,
they work properly.
Change-Id: I52889e092cc9f20bf892c297635b87a972dafa41
2021-01-19 16:31:44 +00:00
|
|
|
/**
|
|
|
|
|
* @defgroup MaintenanceArchive Maintenance archives
|
|
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if ( !defined( 'RUN_MAINTENANCE_IF_MAIN' ) ) {
|
|
|
|
|
// Define this so scripts can easily find doMaintenance.php
|
|
|
|
|
define( 'RUN_MAINTENANCE_IF_MAIN', __DIR__ . '/doMaintenance.php' );
|
|
|
|
|
|
|
|
|
|
// Original name for compat, harmless
|
|
|
|
|
// Support: MediaWiki < 1.31
|
|
|
|
|
define( 'DO_MAINTENANCE', RUN_MAINTENANCE_IF_MAIN );
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-08 02:16:02 +00:00
|
|
|
if ( defined( 'MEDIAWIKI' ) ) {
|
|
|
|
|
// This file is included by many autoloaded class files, and so may
|
|
|
|
|
// potentially be invoked in the context of a web request or another CLI
|
|
|
|
|
// script. It's not appropriate to run the following file-scope code in
|
|
|
|
|
// such a case.
|
|
|
|
|
return;
|
2020-04-11 14:14:09 +00:00
|
|
|
}
|
2019-09-02 23:55:00 +00:00
|
|
|
|
2023-01-11 15:18:50 +00:00
|
|
|
// Abort if called from a web server
|
|
|
|
|
// wfIsCLI() is not available yet
|
|
|
|
|
if ( PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg' ) {
|
|
|
|
|
echo "This script must be run from the command line\n";
|
|
|
|
|
exit( 1 );
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-08 02:16:02 +00:00
|
|
|
define( 'MW_ENTRY_POINT', 'cli' );
|
|
|
|
|
|
2015-04-18 09:37:10 +00:00
|
|
|
// Bail on old versions of PHP, or if composer has not been run yet to install
|
2016-06-15 00:14:20 +00:00
|
|
|
// dependencies.
|
2021-11-16 18:22:57 +00:00
|
|
|
require_once __DIR__ . '/../includes/BootstrapHelperFunctions.php';
|
2016-06-15 00:14:20 +00:00
|
|
|
require_once __DIR__ . '/../includes/PHPVersionCheck.php';
|
2018-10-28 21:12:54 +00:00
|
|
|
wfEntryPointCheck( 'text' );
|
2012-08-27 21:58:28 +00:00
|
|
|
|
2019-10-04 17:59:59 +00:00
|
|
|
/**
|
2023-03-24 02:48:54 +00:00
|
|
|
* @var string|false $maintClass
|
2019-10-04 17:59:59 +00:00
|
|
|
* @phan-var class-string|false
|
|
|
|
|
*/
|
2009-09-04 06:51:38 +00:00
|
|
|
$maintClass = false;
|
2009-08-02 19:35:17 +00:00
|
|
|
|
2019-04-09 07:52:38 +00:00
|
|
|
// Some extensions rely on MW_INSTALL_PATH to find core files to include. Setting it here helps them
|
|
|
|
|
// if they're included by a core script (like DatabaseUpdater) after Maintenance.php has already
|
|
|
|
|
// been run.
|
|
|
|
|
if ( strval( getenv( 'MW_INSTALL_PATH' ) ) === '' ) {
|
|
|
|
|
putenv( 'MW_INSTALL_PATH=' . realpath( __DIR__ . '/..' ) );
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-03 14:33:54 +00:00
|
|
|
require_once __DIR__ . '/includes/Maintenance.php';
|
|
|
|
|
require_once __DIR__ . '/includes/LoggedUpdateMaintenance.php';
|
|
|
|
|
require_once __DIR__ . '/includes/FakeMaintenance.php';
|