MediaWiki REL1_29
install.php
Go to the documentation of this file.
1<?php
24require_once __DIR__ . '/Maintenance.php';
25
26define( 'MW_CONFIG_CALLBACK', 'Installer::overrideConfig' );
27define( 'MEDIAWIKI_INSTALL', true );
28
39 function __construct() {
40 parent::__construct();
41 global $IP;
42
43 $this->addDescription( "CLI-based MediaWiki installation and configuration.\n" .
44 "Default options are indicated in parentheses." );
45
46 $this->addArg( 'name', 'The name of the wiki (MediaWiki)', false );
47
48 $this->addArg( 'admin', 'The username of the wiki administrator.' );
49 $this->addOption( 'pass', 'The password for the wiki administrator.', false, true );
50 $this->addOption(
51 'passfile',
52 'An alternative way to provide pass option, as the contents of this file',
53 false,
54 true
55 );
56 /* $this->addOption( 'email', 'The email for the wiki administrator', false, true ); */
57 $this->addOption(
58 'scriptpath',
59 'The relative path of the wiki in the web server (/wiki)',
60 false,
61 true
62 );
63
64 $this->addOption( 'lang', 'The language to use (en)', false, true );
65 /* $this->addOption( 'cont-lang', 'The content language (en)', false, true ); */
66
67 $this->addOption( 'dbtype', 'The type of database (mysql)', false, true );
68 $this->addOption( 'dbserver', 'The database host (localhost)', false, true );
69 $this->addOption( 'dbport', 'The database port; only for PostgreSQL (5432)', false, true );
70 $this->addOption( 'dbname', 'The database name (my_wiki)', false, true );
71 $this->addOption( 'dbpath', 'The path for the SQLite DB ($IP/data)', false, true );
72 $this->addOption( 'dbprefix', 'Optional database table name prefix', false, true );
73 $this->addOption( 'installdbuser', 'The user to use for installing (root)', false, true );
74 $this->addOption( 'installdbpass', 'The password for the DB user to install as.', false, true );
75 $this->addOption( 'dbuser', 'The user to use for normal operations (wikiuser)', false, true );
76 $this->addOption( 'dbpass', 'The password for the DB user for normal operations', false, true );
77 $this->addOption(
78 'dbpassfile',
79 'An alternative way to provide dbpass option, as the contents of this file',
80 false,
81 true
82 );
83 $this->addOption( 'confpath', "Path to write LocalSettings.php to ($IP)", false, true );
84 $this->addOption( 'dbschema', 'The schema for the MediaWiki DB in '
85 . 'PostgreSQL/Microsoft SQL Server (mediawiki)', false, true );
86 /*
87 $this->addOption( 'namespace', 'The project namespace (same as the "name" argument)',
88 false, true );
89 */
90 $this->addOption( 'env-checks', "Run environment checks only, don't change anything" );
91
92 $this->addOption( 'with-extensions', "Detect and include extensions" );
93 }
94
95 function execute() {
96 global $IP;
97
98 $siteName = $this->getArg( 0, 'MediaWiki' ); // Will not be set if used with --env-checks
99 $adminName = $this->getArg( 1 );
100
101 $dbpassfile = $this->getOption( 'dbpassfile' );
102 if ( $dbpassfile !== null ) {
103 if ( $this->getOption( 'dbpass' ) !== null ) {
104 $this->error( 'WARNING: You have provided the options "dbpass" and "dbpassfile". '
105 . 'The content of "dbpassfile" overrides "dbpass".' );
106 }
107 MediaWiki\suppressWarnings();
108 $dbpass = file_get_contents( $dbpassfile ); // returns false on failure
109 MediaWiki\restoreWarnings();
110 if ( $dbpass === false ) {
111 $this->error( "Couldn't open $dbpassfile", true );
112 }
113 $this->mOptions['dbpass'] = trim( $dbpass, "\r\n" );
114 }
115
116 $passfile = $this->getOption( 'passfile' );
117 if ( $passfile !== null ) {
118 if ( $this->getOption( 'pass' ) !== null ) {
119 $this->error( 'WARNING: You have provided the options "pass" and "passfile". '
120 . 'The content of "passfile" overrides "pass".' );
121 }
122 MediaWiki\suppressWarnings();
123 $pass = file_get_contents( $passfile ); // returns false on failure
124 MediaWiki\restoreWarnings();
125 if ( $pass === false ) {
126 $this->error( "Couldn't open $passfile", true );
127 }
128 $this->mOptions['pass'] = trim( $pass, "\r\n" );
129 } elseif ( $this->getOption( 'pass' ) === null ) {
130 $this->error( 'You need to provide the option "pass" or "passfile"', true );
131 }
132
133 $installer = InstallerOverrides::getCliInstaller( $siteName, $adminName, $this->mOptions );
134
135 $status = $installer->doEnvironmentChecks();
136 if ( $status->isGood() ) {
137 $installer->showMessage( 'config-env-good' );
138 } else {
139 $installer->showStatusMessage( $status );
140
141 return;
142 }
143 if ( !$this->hasOption( 'env-checks' ) ) {
144 $installer->execute();
145 $installer->writeConfigurationFile( $this->getOption( 'confpath', $IP ) );
146 }
147 }
148
150 if ( !$this->hasOption( 'env-checks' ) ) {
151 parent::validateParamsAndArgs();
152 }
153 }
154}
155
156$maintClass = 'CommandLineInstaller';
157
158require_once RUN_MAINTENANCE_IF_MAIN;
$IP
Definition WebStart.php:58
Maintenance script to install and configure MediaWiki.
Definition install.php:38
validateParamsAndArgs()
Run some validation checks on the params, etc.
Definition install.php:149
execute()
Do the actual work.
Definition install.php:95
__construct()
Default constructor.
Definition install.php:39
static getCliInstaller( $siteName, $admin=null, array $options=[])
Instantiates and returns an instance of CliInstaller or its descendant classes.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
error( $err, $die=0)
Throw an error to the user.
addArg( $arg, $description, $required=true)
Add some args that are needed.
hasOption( $name)
Checks to see if a particular param exists.
getArg( $argId=0, $default=null)
Get an argument.
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition hooks.txt:1049
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
$maintClass
Definition install.php:156
require_once RUN_MAINTENANCE_IF_MAIN