2014-05-09 10:24:11 +00:00
|
|
|
#!/usr/bin/env php
|
2004-10-13 07:38:43 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Run all updaters.
|
|
|
|
|
*
|
2008-07-19 12:15:07 +00:00
|
|
|
* This is used when the database schema is modified and we need to apply patches.
|
|
|
|
|
*
|
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
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @file
|
2004-10-13 07:38:43 +00:00
|
|
|
* @todo document
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Maintenance
|
2005-08-02 13:35:19 +00:00
|
|
|
*/
|
2004-10-13 07:38:43 +00:00
|
|
|
|
2021-01-08 02:16:02 +00:00
|
|
|
// NO_AUTOLOAD -- due to hashbang above
|
|
|
|
|
|
2013-05-17 00:16:59 +00:00
|
|
|
require_once __DIR__ . '/Maintenance.php';
|
2009-07-03 06:56:46 +00:00
|
|
|
|
2019-08-26 12:24:37 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2022-11-06 20:35:07 +00:00
|
|
|
use MediaWiki\Settings\SettingsBuilder;
|
2023-02-23 20:44:38 +00:00
|
|
|
use MediaWiki\WikiMap\WikiMap;
|
2019-07-04 07:31:06 +00:00
|
|
|
use Wikimedia\Rdbms\DatabaseSqlite;
|
2017-03-30 20:46:06 +00:00
|
|
|
|
2012-09-03 18:10:09 +00:00
|
|
|
/**
|
|
|
|
|
* Maintenance script to run database schema updates.
|
|
|
|
|
*
|
|
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
2010-09-07 14:33:11 +00:00
|
|
|
class UpdateMediaWiki extends Maintenance {
|
2019-10-09 18:41:33 +00:00
|
|
|
public function __construct() {
|
2010-09-07 14:33:11 +00:00
|
|
|
parent::__construct();
|
2016-01-30 02:48:47 +00:00
|
|
|
$this->addDescription( 'MediaWiki database updater' );
|
2010-09-07 14:33:11 +00:00
|
|
|
$this->addOption( 'skip-compat-checks', 'Skips compatibility checks, mostly for developers' );
|
|
|
|
|
$this->addOption( 'quick', 'Skip 5 second countdown before starting' );
|
|
|
|
|
$this->addOption( 'doshared', 'Also update shared tables' );
|
2012-11-22 03:53:24 +00:00
|
|
|
$this->addOption( 'noschema', 'Only do the updates that are not done during schema updates' );
|
2014-04-22 20:55:25 +00:00
|
|
|
$this->addOption(
|
|
|
|
|
'schema',
|
|
|
|
|
'Output SQL to do the schema updates instead of doing them. Works '
|
|
|
|
|
. 'even when $wgAllowSchemaUpdates is false',
|
|
|
|
|
false,
|
|
|
|
|
true
|
|
|
|
|
);
|
2011-11-03 20:15:27 +00:00
|
|
|
$this->addOption( 'force', 'Override when $wgAllowSchemaUpdates disables this script' );
|
2015-01-31 21:55:13 +00:00
|
|
|
$this->addOption(
|
|
|
|
|
'skip-external-dependencies',
|
|
|
|
|
'Skips checking whether external dependencies are up to date, mostly for developers'
|
|
|
|
|
);
|
2022-07-11 16:02:43 +00:00
|
|
|
$this->addOption(
|
|
|
|
|
'skip-config-validation',
|
|
|
|
|
'Skips checking whether the existing configuration is valid'
|
|
|
|
|
);
|
2010-09-07 14:33:11 +00:00
|
|
|
}
|
2006-04-26 20:42:15 +00:00
|
|
|
|
2019-10-09 18:41:33 +00:00
|
|
|
public function getDbType() {
|
2015-05-11 14:34:02 +00:00
|
|
|
return Maintenance::DB_ADMIN;
|
2010-09-07 14:33:11 +00:00
|
|
|
}
|
2006-11-11 16:59:32 +00:00
|
|
|
|
2019-10-11 19:07:32 +00:00
|
|
|
private function compatChecks() {
|
2015-06-28 01:03:48 +00:00
|
|
|
$minimumPcreVersion = Installer::MINIMUM_PCRE_VERSION;
|
2013-12-16 16:02:51 +00:00
|
|
|
|
2019-05-17 14:54:47 +00:00
|
|
|
$pcreVersion = explode( ' ', PCRE_VERSION, 2 )[0];
|
2013-12-16 16:02:51 +00:00
|
|
|
if ( version_compare( $pcreVersion, $minimumPcreVersion, '<' ) ) {
|
2017-11-20 00:36:54 +00:00
|
|
|
$this->fatalError(
|
2013-12-16 16:02:51 +00:00
|
|
|
"PCRE $minimumPcreVersion or later is required.\n" .
|
|
|
|
|
"Your PHP binary is linked with PCRE $pcreVersion.\n\n" .
|
|
|
|
|
"More information:\n" .
|
|
|
|
|
"https://www.mediawiki.org/wiki/Manual:Errors_and_symptoms/PCRE\n\n" .
|
2017-11-20 00:36:54 +00:00
|
|
|
"ABORTING.\n" );
|
2013-12-16 16:02:51 +00:00
|
|
|
}
|
2010-11-06 22:16:19 +00:00
|
|
|
}
|
|
|
|
|
|
2019-10-09 18:41:33 +00:00
|
|
|
public function execute() {
|
2020-02-25 01:33:18 +00:00
|
|
|
global $wgLang, $wgAllowSchemaUpdates, $wgMessagesDirs;
|
2011-07-13 22:14:19 +00:00
|
|
|
|
2014-04-22 20:55:25 +00:00
|
|
|
if ( !$wgAllowSchemaUpdates
|
|
|
|
|
&& !( $this->hasOption( 'force' )
|
|
|
|
|
|| $this->hasOption( 'schema' )
|
|
|
|
|
|| $this->hasOption( 'noschema' ) )
|
|
|
|
|
) {
|
2017-11-20 00:36:54 +00:00
|
|
|
$this->fatalError( "Do not run update.php on this wiki. If you're seeing this you should\n"
|
2012-11-22 03:53:24 +00:00
|
|
|
. "probably ask for some help in performing your schema updates or use\n"
|
|
|
|
|
. "the --noschema and --schema options to get an SQL file for someone\n"
|
|
|
|
|
. "else to inspect and run.\n\n"
|
2017-11-20 00:36:54 +00:00
|
|
|
. "If you know what you are doing, you can continue with --force\n" );
|
2012-11-22 03:53:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->fileHandle = null;
|
2022-01-21 09:33:31 +00:00
|
|
|
if ( substr( $this->getOption( 'schema', '' ), 0, 2 ) === "--" ) {
|
2017-11-20 00:36:54 +00:00
|
|
|
$this->fatalError( "The --schema option requires a file as an argument.\n" );
|
2013-04-17 14:52:47 +00:00
|
|
|
} elseif ( $this->hasOption( 'schema' ) ) {
|
2012-11-22 03:53:24 +00:00
|
|
|
$file = $this->getOption( 'schema' );
|
|
|
|
|
$this->fileHandle = fopen( $file, "w" );
|
2013-04-17 14:52:47 +00:00
|
|
|
if ( $this->fileHandle === false ) {
|
2012-11-22 03:53:24 +00:00
|
|
|
$err = error_get_last();
|
2017-11-20 00:36:54 +00:00
|
|
|
$this->fatalError( "Problem opening the schema file for writing: $file\n\t{$err['message']}" );
|
2012-11-22 03:53:24 +00:00
|
|
|
}
|
2011-07-13 22:14:19 +00:00
|
|
|
}
|
2004-10-13 07:38:43 +00:00
|
|
|
|
2022-07-11 16:02:43 +00:00
|
|
|
// Check for warnings about settings, and abort if there are any.
|
|
|
|
|
if ( !$this->hasOption( 'skip-config-validation' ) ) {
|
|
|
|
|
$this->validateSettings();
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-11 18:20:30 +00:00
|
|
|
// T206765: We need to load the installer i18n files as some of errors come installer/updater code
|
|
|
|
|
$wgMessagesDirs['MediawikiInstaller'] = dirname( __DIR__ ) . '/includes/installer/i18n';
|
|
|
|
|
|
2019-08-26 12:24:37 +00:00
|
|
|
$lang = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'en' );
|
2017-02-20 22:48:21 +00:00
|
|
|
// Set global language to ensure localised errors are in English (T22633)
|
2016-03-01 21:36:08 +00:00
|
|
|
RequestContext::getMain()->setLanguage( $lang );
|
2020-05-19 22:10:27 +00:00
|
|
|
|
|
|
|
|
// BackCompat
|
|
|
|
|
$wgLang = $lang;
|
2004-12-10 06:05:30 +00:00
|
|
|
|
2013-11-21 00:27:23 +00:00
|
|
|
define( 'MW_UPDATER', true );
|
|
|
|
|
|
2020-02-25 01:33:18 +00:00
|
|
|
$this->output( 'MediaWiki ' . MW_VERSION . " Updater\n\n" );
|
2011-11-11 17:06:03 +00:00
|
|
|
|
2020-05-01 00:36:46 +00:00
|
|
|
MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->waitForReplication();
|
2010-09-07 14:33:11 +00:00
|
|
|
|
2010-09-11 21:56:11 +00:00
|
|
|
if ( !$this->hasOption( 'skip-compat-checks' ) ) {
|
2010-11-06 22:16:19 +00:00
|
|
|
$this->compatChecks();
|
2010-09-07 14:33:11 +00:00
|
|
|
} else {
|
|
|
|
|
$this->output( "Skipping compatibility checks, proceed at your own risk (Ctrl+C to abort)\n" );
|
2017-10-13 00:24:46 +00:00
|
|
|
$this->countDown( 5 );
|
2010-09-07 14:33:11 +00:00
|
|
|
}
|
|
|
|
|
|
2015-01-17 01:49:49 +00:00
|
|
|
// Check external dependencies are up to date
|
2015-01-31 21:55:13 +00:00
|
|
|
if ( !$this->hasOption( 'skip-external-dependencies' ) ) {
|
2018-01-13 00:02:09 +00:00
|
|
|
$composerLockUpToDate = $this->runChild( CheckComposerLockUpToDate::class );
|
2015-01-31 21:55:13 +00:00
|
|
|
$composerLockUpToDate->execute();
|
|
|
|
|
} else {
|
|
|
|
|
$this->output(
|
|
|
|
|
"Skipping checking whether external dependencies are up to date, proceed at your own risk\n"
|
|
|
|
|
);
|
|
|
|
|
}
|
2015-01-17 01:49:49 +00:00
|
|
|
|
2010-09-07 14:33:11 +00:00
|
|
|
# Attempt to connect to the database as a privileged user
|
|
|
|
|
# This will vomit up an error if there are permissions problems
|
2021-04-29 02:37:11 +00:00
|
|
|
$db = $this->getDB( DB_PRIMARY );
|
2010-09-07 14:33:11 +00:00
|
|
|
|
2017-10-03 05:14:33 +00:00
|
|
|
# Check to see whether the database server meets the minimum requirements
|
2020-07-22 22:54:19 +00:00
|
|
|
/** @var DatabaseInstaller $dbInstallerClass */
|
|
|
|
|
$dbInstallerClass = Installer::getDBInstallerClass( $db->getType() );
|
2017-10-03 05:14:33 +00:00
|
|
|
$status = $dbInstallerClass::meetsMinimumRequirement( $db->getServerVersion() );
|
|
|
|
|
if ( !$status->isOK() ) {
|
|
|
|
|
// This might output some wikitext like <strong> but it should be comprehensible
|
|
|
|
|
$text = $status->getWikiText();
|
2017-11-20 00:36:54 +00:00
|
|
|
$this->fatalError( $text );
|
2017-10-03 05:14:33 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-04 07:31:06 +00:00
|
|
|
$dbDomain = WikiMap::getCurrentWikiDbDomain()->getId();
|
|
|
|
|
$this->output( "Going to run database updates for $dbDomain\n" );
|
2013-04-17 14:52:47 +00:00
|
|
|
if ( $db->getType() === 'sqlite' ) {
|
2019-08-31 16:14:38 +00:00
|
|
|
/** @var DatabaseSqlite $db */
|
|
|
|
|
'@phan-var DatabaseSqlite $db';
|
2015-03-07 12:31:08 +00:00
|
|
|
$this->output( "Using SQLite file: '{$db->getDbFilePath()}'\n" );
|
2012-11-06 12:55:58 +00:00
|
|
|
}
|
2010-09-07 14:33:11 +00:00
|
|
|
$this->output( "Depending on the size of your database this may take a while!\n" );
|
|
|
|
|
|
|
|
|
|
if ( !$this->hasOption( 'quick' ) ) {
|
2014-04-22 20:55:25 +00:00
|
|
|
$this->output( "Abort with control-c in the next five seconds "
|
2021-07-21 16:34:05 +00:00
|
|
|
. "(skip this countdown with --quick) ..." );
|
2017-10-13 00:24:46 +00:00
|
|
|
$this->countDown( 5 );
|
2010-09-07 14:33:11 +00:00
|
|
|
}
|
2004-12-10 06:05:30 +00:00
|
|
|
|
2014-05-26 15:02:45 +00:00
|
|
|
$time1 = microtime( true );
|
2013-11-03 14:47:02 +00:00
|
|
|
|
2010-09-07 14:33:11 +00:00
|
|
|
$shared = $this->hasOption( 'doshared' );
|
2011-03-30 20:56:03 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$updates = [ 'core', 'extensions' ];
|
2013-04-17 14:52:47 +00:00
|
|
|
if ( !$this->hasOption( 'schema' ) ) {
|
|
|
|
|
if ( $this->hasOption( 'noschema' ) ) {
|
2012-11-22 03:53:24 +00:00
|
|
|
$updates[] = 'noschema';
|
|
|
|
|
}
|
|
|
|
|
$updates[] = 'stats';
|
|
|
|
|
}
|
2006-01-17 11:48:18 +00:00
|
|
|
|
2016-03-19 00:08:06 +00:00
|
|
|
$updater = DatabaseUpdater::newForDB( $db, $shared, $this );
|
2020-12-12 13:50:50 +00:00
|
|
|
|
2023-02-09 23:21:31 +00:00
|
|
|
// Avoid upgrading from versions older than 1.35
|
|
|
|
|
// Using an implicit marker (ar_user was dropped in 1.34)
|
2020-12-12 13:50:50 +00:00
|
|
|
// TODO: Use an explicit marker
|
|
|
|
|
// See T259771
|
2023-02-09 23:21:31 +00:00
|
|
|
if ( $updater->fieldExists( 'archive', 'ar_user' ) ) {
|
2020-12-12 13:50:50 +00:00
|
|
|
$this->fatalError(
|
2023-02-09 23:21:31 +00:00
|
|
|
"Can not upgrade from versions older than 1.35, please upgrade to that version or later first."
|
2020-12-12 13:50:50 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-30 20:56:03 +00:00
|
|
|
$updater->doUpdates( $updates );
|
2004-10-13 07:38:43 +00:00
|
|
|
|
2013-04-17 14:52:47 +00:00
|
|
|
foreach ( $updater->getPostDatabaseUpdateMaintenance() as $maint ) {
|
2012-10-12 18:52:29 +00:00
|
|
|
$child = $this->runChild( $maint );
|
|
|
|
|
|
|
|
|
|
// LoggedUpdateMaintenance is checking the updatelog itself
|
2015-06-28 01:03:48 +00:00
|
|
|
$isLoggedUpdate = $child instanceof LoggedUpdateMaintenance;
|
2012-10-12 18:52:29 +00:00
|
|
|
|
|
|
|
|
if ( !$isLoggedUpdate && $updater->updateRowExists( $maint ) ) {
|
2011-11-11 17:06:03 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
2012-11-22 03:53:24 +00:00
|
|
|
|
2010-10-26 21:42:49 +00:00
|
|
|
$child->execute();
|
2012-10-12 18:52:29 +00:00
|
|
|
if ( !$isLoggedUpdate ) {
|
|
|
|
|
$updater->insertUpdateRow( $maint );
|
|
|
|
|
}
|
2010-09-07 14:33:11 +00:00
|
|
|
}
|
|
|
|
|
|
2014-11-06 05:43:54 +00:00
|
|
|
$updater->setFileAccess();
|
2021-01-19 14:55:46 +00:00
|
|
|
|
|
|
|
|
$updater->purgeCache();
|
2012-10-15 15:16:37 +00:00
|
|
|
|
2014-05-26 15:02:45 +00:00
|
|
|
$time2 = microtime( true );
|
|
|
|
|
|
2016-03-01 21:36:08 +00:00
|
|
|
$timeDiff = $lang->formatTimePeriod( $time2 - $time1 );
|
2014-05-26 15:02:45 +00:00
|
|
|
$this->output( "\nDone in $timeDiff.\n" );
|
2010-09-07 14:33:11 +00:00
|
|
|
}
|
2004-10-13 07:38:43 +00:00
|
|
|
|
2019-10-11 19:07:32 +00:00
|
|
|
protected function afterFinalSetup() {
|
2010-09-07 20:45:04 +00:00
|
|
|
global $wgLocalisationCacheConf;
|
|
|
|
|
|
|
|
|
|
# Don't try to access the database
|
|
|
|
|
# This needs to be disabled early since extensions will try to use the l10n
|
2017-02-20 22:48:21 +00:00
|
|
|
# cache from $wgExtensionFunctions (T22471)
|
2016-02-17 09:09:32 +00:00
|
|
|
$wgLocalisationCacheConf = [
|
2018-01-13 00:02:09 +00:00
|
|
|
'class' => LocalisationCache::class,
|
|
|
|
|
'storeClass' => LCStoreNull::class,
|
2010-09-07 20:45:04 +00:00
|
|
|
'storeDirectory' => false,
|
|
|
|
|
'manualRecache' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2010-09-07 20:45:04 +00:00
|
|
|
}
|
2019-03-22 02:52:11 +00:00
|
|
|
|
2019-07-11 02:16:49 +00:00
|
|
|
/**
|
|
|
|
|
* @suppress PhanPluginDuplicateConditionalNullCoalescing
|
|
|
|
|
*/
|
2019-03-22 02:52:11 +00:00
|
|
|
public function validateParamsAndArgs() {
|
|
|
|
|
// Allow extensions to add additional params.
|
|
|
|
|
$params = [];
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$this->getHookRunner()->onMaintenanceUpdateAddParams( $params );
|
2019-07-11 02:16:49 +00:00
|
|
|
|
|
|
|
|
// This executes before the PHP version check, so don't use null coalesce (??).
|
|
|
|
|
// Keeping this compatible with older PHP versions lets us reach the code that
|
|
|
|
|
// displays a more helpful error.
|
2019-03-22 02:52:11 +00:00
|
|
|
foreach ( $params as $name => $param ) {
|
|
|
|
|
$this->addOption(
|
|
|
|
|
$name,
|
|
|
|
|
$param['desc'],
|
2019-07-11 02:16:49 +00:00
|
|
|
isset( $param['require'] ) ? $param['require'] : false,
|
|
|
|
|
isset( $param['withArg'] ) ? $param['withArg'] : false,
|
|
|
|
|
isset( $param['shortName'] ) ? $param['shortName'] : false,
|
2019-07-11 13:54:47 +00:00
|
|
|
isset( $param['multiOccurrence'] ) ? $param['multiOccurrence'] : false
|
2019-03-22 02:52:11 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parent::validateParamsAndArgs();
|
|
|
|
|
}
|
2022-07-11 16:02:43 +00:00
|
|
|
|
|
|
|
|
private function formatWarnings( array $warnings ) {
|
|
|
|
|
$text = '';
|
|
|
|
|
foreach ( $warnings as $warning ) {
|
|
|
|
|
$warning = wordwrap( $warning, 75, "\n " );
|
|
|
|
|
$text .= "* $warning\n";
|
|
|
|
|
}
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function validateSettings() {
|
2022-11-06 20:35:07 +00:00
|
|
|
$settings = SettingsBuilder::getInstance();
|
2022-07-11 16:02:43 +00:00
|
|
|
|
|
|
|
|
$warnings = [];
|
2022-11-06 20:35:07 +00:00
|
|
|
if ( $settings->getWarnings() ) {
|
|
|
|
|
$warnings = $settings->getWarnings();
|
2022-07-11 16:02:43 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-06 20:35:07 +00:00
|
|
|
$status = $settings->validate();
|
2022-12-04 19:09:28 +00:00
|
|
|
if ( !$status->isOK() ) {
|
2022-07-11 16:02:43 +00:00
|
|
|
foreach ( $status->getErrorsByType( 'error' ) as $msg ) {
|
|
|
|
|
$msg = wfMessage( $msg['message'], ...$msg['params'] );
|
|
|
|
|
$warnings[] = $msg->text();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-06 20:35:07 +00:00
|
|
|
$deprecations = $settings->detectDeprecatedConfig();
|
2022-07-11 16:02:43 +00:00
|
|
|
foreach ( $deprecations as $key => $msg ) {
|
|
|
|
|
$warnings[] = "$key is deprecated: $msg";
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-06 20:35:07 +00:00
|
|
|
$obsolete = $settings->detectObsoleteConfig();
|
2022-10-05 10:02:45 +00:00
|
|
|
foreach ( $obsolete as $key => $msg ) {
|
|
|
|
|
$warnings[] = "$key is obsolete: $msg";
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-11 16:02:43 +00:00
|
|
|
if ( $warnings ) {
|
|
|
|
|
$this->fatalError( "Some of your configuration settings caused a warning:\n\n"
|
|
|
|
|
. $this->formatWarnings( $warnings ) . "\n"
|
|
|
|
|
. "Please correct the issue before running update.php again.\n"
|
|
|
|
|
. "If you know what you are doing, you can bypass this check\n"
|
|
|
|
|
. "using --skip-config-validation.\n" );
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-09-04 02:03:23 +00:00
|
|
|
}
|
2010-09-07 14:33:11 +00:00
|
|
|
|
2018-01-13 00:02:09 +00:00
|
|
|
$maintClass = UpdateMediaWiki::class;
|
2013-05-07 23:00:15 +00:00
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|