2010-06-23 01:08:34 +00:00
|
|
|
<?php
|
2010-08-21 18:20:09 +00:00
|
|
|
/**
|
|
|
|
|
* Core installer command line interface.
|
|
|
|
|
*
|
2012-05-06 05:50:15 +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
|
|
|
|
|
*
|
2010-08-21 18:20:09 +00:00
|
|
|
* @file
|
|
|
|
|
* @ingroup Deployment
|
|
|
|
|
*/
|
2010-06-23 01:08:34 +00:00
|
|
|
|
2018-07-29 12:24:54 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
/**
|
|
|
|
|
* Class for the core installer command line interface.
|
2010-07-30 20:17:28 +00:00
|
|
|
*
|
2010-07-29 18:36:39 +00:00
|
|
|
* @ingroup Deployment
|
2010-07-22 17:58:26 +00:00
|
|
|
* @since 1.17
|
|
|
|
|
*/
|
2011-01-21 15:27:16 +00:00
|
|
|
class CliInstaller extends Installer {
|
2011-08-03 15:46:06 +00:00
|
|
|
private $specifiedScriptPath = false;
|
2010-07-30 20:17:28 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
private $optionMap = [
|
2010-06-27 21:48:51 +00:00
|
|
|
'dbtype' => 'wgDBtype',
|
|
|
|
|
'dbserver' => 'wgDBserver',
|
|
|
|
|
'dbname' => 'wgDBname',
|
|
|
|
|
'dbuser' => 'wgDBuser',
|
|
|
|
|
'dbpass' => 'wgDBpassword',
|
|
|
|
|
'dbprefix' => 'wgDBprefix',
|
|
|
|
|
'dbtableoptions' => 'wgDBTableOptions',
|
|
|
|
|
'dbport' => 'wgDBport',
|
|
|
|
|
'dbschema' => 'wgDBmwschema',
|
|
|
|
|
'dbpath' => 'wgSQLiteDataDir',
|
2011-11-06 01:15:25 +00:00
|
|
|
'server' => 'wgServer',
|
2010-10-02 07:39:17 +00:00
|
|
|
'scriptpath' => 'wgScriptPath',
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2010-06-27 21:48:51 +00:00
|
|
|
|
2010-07-29 18:03:25 +00:00
|
|
|
/**
|
2014-04-19 11:55:27 +00:00
|
|
|
* @param string $siteName
|
2018-06-26 21:14:43 +00:00
|
|
|
* @param string|null $admin
|
install.php: Allow extensions and skins to be specified
Allow the extensions and skins installed by maintenance/install.php to
be customised using --skins= and --extensions=. If the argument is
am empty string then no extensions/skins are installed. For backwards
compatibility, the default is to install all skins, but to install all
extensions only if --with-extensions is given.
The new CLI options may be specified multiple times, but for
convenience, comma-separated lists can also be used.
Also:
* Rename $option to $options
* If an extension has a dependency error, propagate the very readable
error message generated by ExtensionRegistry back to the user.
* Split getExtensionInfo() from the loop body of findExtensionsByType(),
so that CliInstaller can use it to validate its parameters and get
error messages.
* I didn't like the idea of removing the "s" from the directory name in
order to construct the JSON file name, so I split
findExtensionsByType() from findExtensions(), with the former not
having this hack. In findExtensions(), make the previous assumption
that the directory name is always "extensions" or "skins" explicit,
throwing an exception if it is otherwise.
Change-Id: Id0fb63cd4e61a047ef3396ee1c38d6073dfc7fd1
2018-09-19 05:43:14 +00:00
|
|
|
* @param array $options
|
2010-07-29 18:03:25 +00:00
|
|
|
*/
|
install.php: Allow extensions and skins to be specified
Allow the extensions and skins installed by maintenance/install.php to
be customised using --skins= and --extensions=. If the argument is
am empty string then no extensions/skins are installed. For backwards
compatibility, the default is to install all skins, but to install all
extensions only if --with-extensions is given.
The new CLI options may be specified multiple times, but for
convenience, comma-separated lists can also be used.
Also:
* Rename $option to $options
* If an extension has a dependency error, propagate the very readable
error message generated by ExtensionRegistry back to the user.
* Split getExtensionInfo() from the loop body of findExtensionsByType(),
so that CliInstaller can use it to validate its parameters and get
error messages.
* I didn't like the idea of removing the "s" from the directory name in
order to construct the JSON file name, so I split
findExtensionsByType() from findExtensions(), with the former not
having this hack. In findExtensions(), make the previous assumption
that the directory name is always "extensions" or "skins" explicit,
throwing an exception if it is otherwise.
Change-Id: Id0fb63cd4e61a047ef3396ee1c38d6073dfc7fd1
2018-09-19 05:43:14 +00:00
|
|
|
function __construct( $siteName, $admin = null, array $options = [] ) {
|
2011-03-20 17:36:18 +00:00
|
|
|
global $wgContLang;
|
|
|
|
|
|
2010-06-23 01:08:34 +00:00
|
|
|
parent::__construct();
|
|
|
|
|
|
install.php: Allow extensions and skins to be specified
Allow the extensions and skins installed by maintenance/install.php to
be customised using --skins= and --extensions=. If the argument is
am empty string then no extensions/skins are installed. For backwards
compatibility, the default is to install all skins, but to install all
extensions only if --with-extensions is given.
The new CLI options may be specified multiple times, but for
convenience, comma-separated lists can also be used.
Also:
* Rename $option to $options
* If an extension has a dependency error, propagate the very readable
error message generated by ExtensionRegistry back to the user.
* Split getExtensionInfo() from the loop body of findExtensionsByType(),
so that CliInstaller can use it to validate its parameters and get
error messages.
* I didn't like the idea of removing the "s" from the directory name in
order to construct the JSON file name, so I split
findExtensionsByType() from findExtensions(), with the former not
having this hack. In findExtensions(), make the previous assumption
that the directory name is always "extensions" or "skins" explicit,
throwing an exception if it is otherwise.
Change-Id: Id0fb63cd4e61a047ef3396ee1c38d6073dfc7fd1
2018-09-19 05:43:14 +00:00
|
|
|
if ( isset( $options['scriptpath'] ) ) {
|
2011-08-03 15:46:06 +00:00
|
|
|
$this->specifiedScriptPath = true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-27 21:48:51 +00:00
|
|
|
foreach ( $this->optionMap as $opt => $global ) {
|
install.php: Allow extensions and skins to be specified
Allow the extensions and skins installed by maintenance/install.php to
be customised using --skins= and --extensions=. If the argument is
am empty string then no extensions/skins are installed. For backwards
compatibility, the default is to install all skins, but to install all
extensions only if --with-extensions is given.
The new CLI options may be specified multiple times, but for
convenience, comma-separated lists can also be used.
Also:
* Rename $option to $options
* If an extension has a dependency error, propagate the very readable
error message generated by ExtensionRegistry back to the user.
* Split getExtensionInfo() from the loop body of findExtensionsByType(),
so that CliInstaller can use it to validate its parameters and get
error messages.
* I didn't like the idea of removing the "s" from the directory name in
order to construct the JSON file name, so I split
findExtensionsByType() from findExtensions(), with the former not
having this hack. In findExtensions(), make the previous assumption
that the directory name is always "extensions" or "skins" explicit,
throwing an exception if it is otherwise.
Change-Id: Id0fb63cd4e61a047ef3396ee1c38d6073dfc7fd1
2018-09-19 05:43:14 +00:00
|
|
|
if ( isset( $options[$opt] ) ) {
|
|
|
|
|
$GLOBALS[$global] = $options[$opt];
|
|
|
|
|
$this->setVar( $global, $options[$opt] );
|
2010-06-27 21:48:51 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
install.php: Allow extensions and skins to be specified
Allow the extensions and skins installed by maintenance/install.php to
be customised using --skins= and --extensions=. If the argument is
am empty string then no extensions/skins are installed. For backwards
compatibility, the default is to install all skins, but to install all
extensions only if --with-extensions is given.
The new CLI options may be specified multiple times, but for
convenience, comma-separated lists can also be used.
Also:
* Rename $option to $options
* If an extension has a dependency error, propagate the very readable
error message generated by ExtensionRegistry back to the user.
* Split getExtensionInfo() from the loop body of findExtensionsByType(),
so that CliInstaller can use it to validate its parameters and get
error messages.
* I didn't like the idea of removing the "s" from the directory name in
order to construct the JSON file name, so I split
findExtensionsByType() from findExtensions(), with the former not
having this hack. In findExtensions(), make the previous assumption
that the directory name is always "extensions" or "skins" explicit,
throwing an exception if it is otherwise.
Change-Id: Id0fb63cd4e61a047ef3396ee1c38d6073dfc7fd1
2018-09-19 05:43:14 +00:00
|
|
|
if ( isset( $options['lang'] ) ) {
|
2011-03-20 17:36:18 +00:00
|
|
|
global $wgLang, $wgLanguageCode;
|
install.php: Allow extensions and skins to be specified
Allow the extensions and skins installed by maintenance/install.php to
be customised using --skins= and --extensions=. If the argument is
am empty string then no extensions/skins are installed. For backwards
compatibility, the default is to install all skins, but to install all
extensions only if --with-extensions is given.
The new CLI options may be specified multiple times, but for
convenience, comma-separated lists can also be used.
Also:
* Rename $option to $options
* If an extension has a dependency error, propagate the very readable
error message generated by ExtensionRegistry back to the user.
* Split getExtensionInfo() from the loop body of findExtensionsByType(),
so that CliInstaller can use it to validate its parameters and get
error messages.
* I didn't like the idea of removing the "s" from the directory name in
order to construct the JSON file name, so I split
findExtensionsByType() from findExtensions(), with the former not
having this hack. In findExtensions(), make the previous assumption
that the directory name is always "extensions" or "skins" explicit,
throwing an exception if it is otherwise.
Change-Id: Id0fb63cd4e61a047ef3396ee1c38d6073dfc7fd1
2018-09-19 05:43:14 +00:00
|
|
|
$this->setVar( '_UserLang', $options['lang'] );
|
|
|
|
|
$wgLanguageCode = $options['lang'];
|
2018-12-03 10:48:08 +00:00
|
|
|
$this->setVar( 'wgLanguageCode', $wgLanguageCode );
|
2018-07-29 12:24:54 +00:00
|
|
|
$wgContLang = MediaWikiServices::getInstance()->getContentLanguage();
|
install.php: Allow extensions and skins to be specified
Allow the extensions and skins installed by maintenance/install.php to
be customised using --skins= and --extensions=. If the argument is
am empty string then no extensions/skins are installed. For backwards
compatibility, the default is to install all skins, but to install all
extensions only if --with-extensions is given.
The new CLI options may be specified multiple times, but for
convenience, comma-separated lists can also be used.
Also:
* Rename $option to $options
* If an extension has a dependency error, propagate the very readable
error message generated by ExtensionRegistry back to the user.
* Split getExtensionInfo() from the loop body of findExtensionsByType(),
so that CliInstaller can use it to validate its parameters and get
error messages.
* I didn't like the idea of removing the "s" from the directory name in
order to construct the JSON file name, so I split
findExtensionsByType() from findExtensions(), with the former not
having this hack. In findExtensions(), make the previous assumption
that the directory name is always "extensions" or "skins" explicit,
throwing an exception if it is otherwise.
Change-Id: Id0fb63cd4e61a047ef3396ee1c38d6073dfc7fd1
2018-09-19 05:43:14 +00:00
|
|
|
$wgLang = Language::factory( $options['lang'] );
|
2016-02-10 10:32:38 +00:00
|
|
|
RequestContext::getMain()->setLanguage( $wgLang );
|
2010-06-23 01:08:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->setVar( 'wgSitename', $siteName );
|
2010-09-04 01:06:34 +00:00
|
|
|
|
2011-03-20 17:36:18 +00:00
|
|
|
$metaNS = $wgContLang->ucfirst( str_replace( ' ', '_', $siteName ) );
|
|
|
|
|
if ( $metaNS == 'MediaWiki' ) {
|
|
|
|
|
$metaNS = 'Project';
|
|
|
|
|
}
|
|
|
|
|
$this->setVar( 'wgMetaNamespace', $metaNS );
|
|
|
|
|
|
2010-06-23 01:08:34 +00:00
|
|
|
if ( $admin ) {
|
|
|
|
|
$this->setVar( '_AdminName', $admin );
|
|
|
|
|
}
|
2010-06-27 21:48:51 +00:00
|
|
|
|
install.php: Allow extensions and skins to be specified
Allow the extensions and skins installed by maintenance/install.php to
be customised using --skins= and --extensions=. If the argument is
am empty string then no extensions/skins are installed. For backwards
compatibility, the default is to install all skins, but to install all
extensions only if --with-extensions is given.
The new CLI options may be specified multiple times, but for
convenience, comma-separated lists can also be used.
Also:
* Rename $option to $options
* If an extension has a dependency error, propagate the very readable
error message generated by ExtensionRegistry back to the user.
* Split getExtensionInfo() from the loop body of findExtensionsByType(),
so that CliInstaller can use it to validate its parameters and get
error messages.
* I didn't like the idea of removing the "s" from the directory name in
order to construct the JSON file name, so I split
findExtensionsByType() from findExtensions(), with the former not
having this hack. In findExtensions(), make the previous assumption
that the directory name is always "extensions" or "skins" explicit,
throwing an exception if it is otherwise.
Change-Id: Id0fb63cd4e61a047ef3396ee1c38d6073dfc7fd1
2018-09-19 05:43:14 +00:00
|
|
|
if ( !isset( $options['installdbuser'] ) ) {
|
2010-06-27 21:48:51 +00:00
|
|
|
$this->setVar( '_InstallUser',
|
|
|
|
|
$this->getVar( 'wgDBuser' ) );
|
|
|
|
|
$this->setVar( '_InstallPassword',
|
|
|
|
|
$this->getVar( 'wgDBpassword' ) );
|
2011-06-09 15:42:23 +00:00
|
|
|
} else {
|
|
|
|
|
$this->setVar( '_InstallUser',
|
install.php: Allow extensions and skins to be specified
Allow the extensions and skins installed by maintenance/install.php to
be customised using --skins= and --extensions=. If the argument is
am empty string then no extensions/skins are installed. For backwards
compatibility, the default is to install all skins, but to install all
extensions only if --with-extensions is given.
The new CLI options may be specified multiple times, but for
convenience, comma-separated lists can also be used.
Also:
* Rename $option to $options
* If an extension has a dependency error, propagate the very readable
error message generated by ExtensionRegistry back to the user.
* Split getExtensionInfo() from the loop body of findExtensionsByType(),
so that CliInstaller can use it to validate its parameters and get
error messages.
* I didn't like the idea of removing the "s" from the directory name in
order to construct the JSON file name, so I split
findExtensionsByType() from findExtensions(), with the former not
having this hack. In findExtensions(), make the previous assumption
that the directory name is always "extensions" or "skins" explicit,
throwing an exception if it is otherwise.
Change-Id: Id0fb63cd4e61a047ef3396ee1c38d6073dfc7fd1
2018-09-19 05:43:14 +00:00
|
|
|
$options['installdbuser'] );
|
2011-06-09 15:42:23 +00:00
|
|
|
$this->setVar( '_InstallPassword',
|
install.php: Allow extensions and skins to be specified
Allow the extensions and skins installed by maintenance/install.php to
be customised using --skins= and --extensions=. If the argument is
am empty string then no extensions/skins are installed. For backwards
compatibility, the default is to install all skins, but to install all
extensions only if --with-extensions is given.
The new CLI options may be specified multiple times, but for
convenience, comma-separated lists can also be used.
Also:
* Rename $option to $options
* If an extension has a dependency error, propagate the very readable
error message generated by ExtensionRegistry back to the user.
* Split getExtensionInfo() from the loop body of findExtensionsByType(),
so that CliInstaller can use it to validate its parameters and get
error messages.
* I didn't like the idea of removing the "s" from the directory name in
order to construct the JSON file name, so I split
findExtensionsByType() from findExtensions(), with the former not
having this hack. In findExtensions(), make the previous assumption
that the directory name is always "extensions" or "skins" explicit,
throwing an exception if it is otherwise.
Change-Id: Id0fb63cd4e61a047ef3396ee1c38d6073dfc7fd1
2018-09-19 05:43:14 +00:00
|
|
|
$options['installdbpass'] ?? "" );
|
2011-10-11 21:24:00 +00:00
|
|
|
|
|
|
|
|
// Assume that if we're given the installer user, we'll create the account.
|
|
|
|
|
$this->setVar( '_CreateDBAccount', true );
|
2010-06-27 21:48:51 +00:00
|
|
|
}
|
|
|
|
|
|
install.php: Allow extensions and skins to be specified
Allow the extensions and skins installed by maintenance/install.php to
be customised using --skins= and --extensions=. If the argument is
am empty string then no extensions/skins are installed. For backwards
compatibility, the default is to install all skins, but to install all
extensions only if --with-extensions is given.
The new CLI options may be specified multiple times, but for
convenience, comma-separated lists can also be used.
Also:
* Rename $option to $options
* If an extension has a dependency error, propagate the very readable
error message generated by ExtensionRegistry back to the user.
* Split getExtensionInfo() from the loop body of findExtensionsByType(),
so that CliInstaller can use it to validate its parameters and get
error messages.
* I didn't like the idea of removing the "s" from the directory name in
order to construct the JSON file name, so I split
findExtensionsByType() from findExtensions(), with the former not
having this hack. In findExtensions(), make the previous assumption
that the directory name is always "extensions" or "skins" explicit,
throwing an exception if it is otherwise.
Change-Id: Id0fb63cd4e61a047ef3396ee1c38d6073dfc7fd1
2018-09-19 05:43:14 +00:00
|
|
|
if ( isset( $options['pass'] ) ) {
|
|
|
|
|
$this->setVar( '_AdminPassword', $options['pass'] );
|
2010-06-27 21:48:51 +00:00
|
|
|
}
|
2014-09-13 18:34:52 +00:00
|
|
|
|
2018-03-13 09:16:15 +00:00
|
|
|
// Detect and inject any extension found
|
install.php: Allow extensions and skins to be specified
Allow the extensions and skins installed by maintenance/install.php to
be customised using --skins= and --extensions=. If the argument is
am empty string then no extensions/skins are installed. For backwards
compatibility, the default is to install all skins, but to install all
extensions only if --with-extensions is given.
The new CLI options may be specified multiple times, but for
convenience, comma-separated lists can also be used.
Also:
* Rename $option to $options
* If an extension has a dependency error, propagate the very readable
error message generated by ExtensionRegistry back to the user.
* Split getExtensionInfo() from the loop body of findExtensionsByType(),
so that CliInstaller can use it to validate its parameters and get
error messages.
* I didn't like the idea of removing the "s" from the directory name in
order to construct the JSON file name, so I split
findExtensionsByType() from findExtensions(), with the former not
having this hack. In findExtensions(), make the previous assumption
that the directory name is always "extensions" or "skins" explicit,
throwing an exception if it is otherwise.
Change-Id: Id0fb63cd4e61a047ef3396ee1c38d6073dfc7fd1
2018-09-19 05:43:14 +00:00
|
|
|
if ( isset( $options['extensions'] ) ) {
|
|
|
|
|
$status = $this->validateExtensions(
|
|
|
|
|
'extension', 'extensions', $options['extensions'] );
|
|
|
|
|
if ( !$status->isOK() ) {
|
|
|
|
|
$this->showStatusMessage( $status );
|
|
|
|
|
}
|
|
|
|
|
$this->setVar( '_Extensions', $status->value );
|
|
|
|
|
} elseif ( isset( $options['with-extensions'] ) ) {
|
2018-03-13 09:16:15 +00:00
|
|
|
$this->setVar( '_Extensions', array_keys( $this->findExtensions() ) );
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 18:34:52 +00:00
|
|
|
// Set up the default skins
|
install.php: Allow extensions and skins to be specified
Allow the extensions and skins installed by maintenance/install.php to
be customised using --skins= and --extensions=. If the argument is
am empty string then no extensions/skins are installed. For backwards
compatibility, the default is to install all skins, but to install all
extensions only if --with-extensions is given.
The new CLI options may be specified multiple times, but for
convenience, comma-separated lists can also be used.
Also:
* Rename $option to $options
* If an extension has a dependency error, propagate the very readable
error message generated by ExtensionRegistry back to the user.
* Split getExtensionInfo() from the loop body of findExtensionsByType(),
so that CliInstaller can use it to validate its parameters and get
error messages.
* I didn't like the idea of removing the "s" from the directory name in
order to construct the JSON file name, so I split
findExtensionsByType() from findExtensions(), with the former not
having this hack. In findExtensions(), make the previous assumption
that the directory name is always "extensions" or "skins" explicit,
throwing an exception if it is otherwise.
Change-Id: Id0fb63cd4e61a047ef3396ee1c38d6073dfc7fd1
2018-09-19 05:43:14 +00:00
|
|
|
if ( isset( $options['skins'] ) ) {
|
|
|
|
|
$status = $this->validateExtensions( 'skin', 'skins', $options['skins'] );
|
|
|
|
|
if ( !$status->isOK() ) {
|
|
|
|
|
$this->showStatusMessage( $status );
|
|
|
|
|
}
|
|
|
|
|
$skins = $status->value;
|
|
|
|
|
} else {
|
|
|
|
|
$skins = array_keys( $this->findExtensions( 'skins' ) );
|
|
|
|
|
}
|
2014-09-13 18:34:52 +00:00
|
|
|
$this->setVar( '_Skins', $skins );
|
|
|
|
|
|
|
|
|
|
if ( $skins ) {
|
|
|
|
|
$skinNames = array_map( 'strtolower', $skins );
|
|
|
|
|
$this->setVar( 'wgDefaultSkin', $this->getDefaultSkin( $skinNames ) );
|
|
|
|
|
}
|
2010-06-23 01:08:34 +00:00
|
|
|
}
|
|
|
|
|
|
install.php: Allow extensions and skins to be specified
Allow the extensions and skins installed by maintenance/install.php to
be customised using --skins= and --extensions=. If the argument is
am empty string then no extensions/skins are installed. For backwards
compatibility, the default is to install all skins, but to install all
extensions only if --with-extensions is given.
The new CLI options may be specified multiple times, but for
convenience, comma-separated lists can also be used.
Also:
* Rename $option to $options
* If an extension has a dependency error, propagate the very readable
error message generated by ExtensionRegistry back to the user.
* Split getExtensionInfo() from the loop body of findExtensionsByType(),
so that CliInstaller can use it to validate its parameters and get
error messages.
* I didn't like the idea of removing the "s" from the directory name in
order to construct the JSON file name, so I split
findExtensionsByType() from findExtensions(), with the former not
having this hack. In findExtensions(), make the previous assumption
that the directory name is always "extensions" or "skins" explicit,
throwing an exception if it is otherwise.
Change-Id: Id0fb63cd4e61a047ef3396ee1c38d6073dfc7fd1
2018-09-19 05:43:14 +00:00
|
|
|
private function validateExtensions( $type, $directory, $nameLists ) {
|
|
|
|
|
$extensions = [];
|
|
|
|
|
$status = new Status;
|
|
|
|
|
foreach ( (array)$nameLists as $nameList ) {
|
|
|
|
|
foreach ( explode( ',', $nameList ) as $name ) {
|
|
|
|
|
$name = trim( $name );
|
|
|
|
|
if ( $name === '' ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$extStatus = $this->getExtensionInfo( $type, $directory, $name );
|
|
|
|
|
if ( $extStatus->isOK() ) {
|
|
|
|
|
$extensions[] = $name;
|
|
|
|
|
} else {
|
|
|
|
|
$status->merge( $extStatus );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$extensions = array_unique( $extensions );
|
|
|
|
|
$status->value = $extensions;
|
|
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-23 01:08:34 +00:00
|
|
|
/**
|
|
|
|
|
* Main entry point.
|
|
|
|
|
*/
|
2010-07-19 03:16:54 +00:00
|
|
|
public function execute() {
|
2011-06-05 21:03:39 +00:00
|
|
|
$vars = Installer::getExistingLocalSettings();
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( $vars ) {
|
2010-12-19 04:55:00 +00:00
|
|
|
$this->showStatusMessage(
|
|
|
|
|
Status::newFatal( "config-localsettings-cli-upgrade" )
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-18 18:52:05 +00:00
|
|
|
$this->performInstallation(
|
2016-02-17 09:09:32 +00:00
|
|
|
[ $this, 'startStage' ],
|
|
|
|
|
[ $this, 'endStage' ]
|
2010-07-18 18:52:05 +00:00
|
|
|
);
|
2010-11-02 17:11:35 +00:00
|
|
|
}
|
2010-07-30 20:17:28 +00:00
|
|
|
|
2010-11-02 17:11:35 +00:00
|
|
|
/**
|
|
|
|
|
* Write LocalSettings.php to a given path
|
|
|
|
|
*
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $path Full path to write LocalSettings.php to
|
2010-11-02 17:11:35 +00:00
|
|
|
*/
|
|
|
|
|
public function writeConfigurationFile( $path ) {
|
2012-06-12 16:18:44 +00:00
|
|
|
$ls = InstallerOverrides::getLocalSettingsGenerator( $this );
|
2010-11-02 17:11:35 +00:00
|
|
|
$ls->writeFile( "$path/LocalSettings.php" );
|
2010-07-18 18:52:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function startStage( $step ) {
|
2013-08-28 00:38:27 +00:00
|
|
|
// Messages: config-install-database, config-install-tables, config-install-interwiki,
|
2014-04-14 20:46:09 +00:00
|
|
|
// config-install-stats, config-install-keys, config-install-sysop, config-install-mainpage,
|
|
|
|
|
// config-install-extensions
|
2011-04-02 07:34:07 +00:00
|
|
|
$this->showMessage( "config-install-$step" );
|
2010-07-18 18:52:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function endStage( $step, $status ) {
|
2010-12-19 04:55:00 +00:00
|
|
|
$this->showStatusMessage( $status );
|
2011-04-02 07:34:07 +00:00
|
|
|
$this->showMessage( 'config-install-step-done' );
|
2010-06-23 01:08:34 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-19 03:16:54 +00:00
|
|
|
public function showMessage( $msg /*, ... */ ) {
|
2011-04-27 18:22:01 +00:00
|
|
|
echo $this->getMessageText( func_get_args() ) . "\n";
|
|
|
|
|
flush();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function showError( $msg /*, ... */ ) {
|
|
|
|
|
echo "***{$this->getMessageText( func_get_args() )}***\n";
|
|
|
|
|
flush();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-04-19 11:55:27 +00:00
|
|
|
* @param array $params
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
2011-04-27 18:22:01 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
protected function getMessageText( $params ) {
|
|
|
|
|
$msg = array_shift( $params );
|
2010-12-19 04:55:00 +00:00
|
|
|
|
2012-07-24 01:04:15 +00:00
|
|
|
$text = wfMessage( $msg, $params )->parse();
|
2011-03-19 15:27:24 +00:00
|
|
|
|
2010-11-16 18:13:35 +00:00
|
|
|
$text = preg_replace( '/<a href="(.*?)".*?>(.*?)<\/a>/', '$2 <$1>', $text );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2017-07-07 23:35:07 +00:00
|
|
|
return Sanitizer::stripAllTags( $text );
|
2011-04-27 18:22:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Dummy
|
|
|
|
|
*/
|
|
|
|
|
public function showHelpBox( $msg /*, ... */ ) {
|
2010-06-23 01:08:34 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-29 15:20:04 +00:00
|
|
|
public function showStatusMessage( Status $status ) {
|
2014-07-21 08:31:09 +00:00
|
|
|
$warnings = array_merge( $status->getWarningsArray(),
|
|
|
|
|
$status->getErrorsArray() );
|
|
|
|
|
|
|
|
|
|
if ( count( $warnings ) !== 0 ) {
|
|
|
|
|
foreach ( $warnings as $w ) {
|
2018-06-05 06:24:34 +00:00
|
|
|
$this->showMessage( ...$w );
|
2014-07-21 08:31:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-19 00:08:06 +00:00
|
|
|
if ( !$status->isOK() ) {
|
2010-12-19 04:55:00 +00:00
|
|
|
echo "\n";
|
2012-07-07 18:09:45 +00:00
|
|
|
exit( 1 );
|
2010-12-19 04:55:00 +00:00
|
|
|
}
|
2010-06-23 01:08:34 +00:00
|
|
|
}
|
2011-08-03 15:46:06 +00:00
|
|
|
|
2013-03-17 15:13:22 +00:00
|
|
|
public function envCheckPath() {
|
2011-08-03 15:46:06 +00:00
|
|
|
if ( !$this->specifiedScriptPath ) {
|
2013-02-03 19:28:43 +00:00
|
|
|
$this->showMessage( 'config-no-cli-uri', $this->getVar( "wgScriptPath" ) );
|
2011-08-03 15:46:06 +00:00
|
|
|
}
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2011-08-03 15:46:06 +00:00
|
|
|
return parent::envCheckPath();
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-12 15:11:08 +00:00
|
|
|
protected function envGetDefaultServer() {
|
2013-10-06 19:41:18 +00:00
|
|
|
return null; // Do not guess if installing from CLI
|
2011-11-29 17:59:52 +00:00
|
|
|
}
|
|
|
|
|
|
2011-08-03 15:46:06 +00:00
|
|
|
public function dirIsExecutable( $dir, $url ) {
|
|
|
|
|
$this->showMessage( 'config-no-cli-uploads-check', $dir );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2011-08-03 15:46:06 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
}
|