89 && !( $this->hasOption(
'force' )
90 || $this->hasOption(
'schema' )
91 || $this->hasOption(
'noschema' ) )
93 $this->fatalError(
"Do not run update.php on this wiki. If you're seeing this you should\n"
94 .
"probably ask for some help in performing your schema updates or use\n"
95 .
"the --noschema and --schema options to get an SQL file for someone\n"
96 .
"else to inspect and run.\n\n"
97 .
"If you know what you are doing, you can continue with --force\n" );
100 $this->fileHandle =
null;
101 if ( str_starts_with( $this->getOption(
'schema',
'' ),
'--' ) ) {
102 $this->fatalError(
"The --schema option requires a file as an argument.\n" );
103 } elseif ( $this->hasOption(
'schema' ) ) {
104 $file = $this->getOption(
'schema' );
105 $this->fileHandle = fopen( $file,
"w" );
106 if ( $this->fileHandle ===
false ) {
107 $err = error_get_last();
108 $this->fatalError(
"Problem opening the schema file for writing: $file\n\t{$err['message']}" );
113 if ( !$this->hasOption(
'skip-config-validation' ) ) {
114 $this->validateSettings();
117 $lang = $this->getServiceContainer()->getLanguageFactory()->getLanguage(
'en' );
119 RequestContext::getMain()->setLanguage( $lang );
124 define(
'MW_UPDATER',
true );
126 $this->output(
'MediaWiki ' .
MW_VERSION .
" Updater\n\n" );
128 $this->waitForReplication();
131 if ( !$this->hasOption(
'skip-external-dependencies' ) && !getenv(
'MW_SKIP_EXTERNAL_DEPENDENCIES' ) ) {
132 $composerLockUpToDate = $this->runChild( CheckComposerLockUpToDate::class );
133 $composerLockUpToDate->execute();
136 "Skipping checking whether external dependencies are up to date, proceed at your own risk\n"
140 # Attempt to connect to the database as a privileged user
141 # This will vomit up an error if there are permissions problems
142 $db = $this->getPrimaryDB();
144 # Check to see whether the database server meets the minimum requirements
146 $dbInstallerClass = Installer::getDBInstallerClass( $db->getType() );
147 $status = $dbInstallerClass::meetsMinimumRequirement( $db );
148 if ( !$status->isOK() ) {
150 $this->fatalError( $status );
153 $dbDomain = WikiMap::getCurrentWikiDbDomain()->getId();
154 $this->output(
"Going to run database updates for $dbDomain\n" );
155 if ( $db->getType() ===
'sqlite' ) {
157 '@phan-var DatabaseSqlite $db';
158 $this->output(
"Using SQLite file: '{$db->getDbFilePath()}'\n" );
160 $this->output(
"Depending on the size of your database this may take a while!\n" );
162 if ( !$this->hasOption(
'quick' ) ) {
163 $this->output(
"Abort with control-c in the next five seconds "
164 .
"(skip this countdown with --quick) ..." );
165 $this->countDown( 5 );
168 $time1 = microtime(
true );
170 $shared = $this->hasOption(
'doshared' );
172 $updates = [
'core',
'extensions' ];
173 if ( !$this->hasOption(
'schema' ) ) {
174 if ( $this->hasOption(
'noschema' ) ) {
175 $updates[] =
'noschema';
177 $updates[] =
'stats';
179 if ( $this->hasOption(
'initial' ) ) {
180 $updates[] =
'initial';
183 $updater = DatabaseUpdater::newForDB( $db, $shared, $this );
189 if ( !$updater->fieldExists(
'revision',
'rev_actor' ) ) {
191 "Can not upgrade from versions older than 1.35, please upgrade to that version or later first."
195 $updater->doUpdates( $updates );
197 foreach ( $updater->getPostDatabaseUpdateMaintenance() as $maint ) {
198 $child = $this->runChild( $maint );
201 $isLoggedUpdate = $child instanceof LoggedUpdateMaintenance;
203 if ( !$isLoggedUpdate && $updater->updateRowExists( $maint ) ) {
208 if ( !$isLoggedUpdate ) {
209 $updater->insertUpdateRow( $maint );
213 $updater->setFileAccess();
215 $updater->purgeCache();
217 $time2 = microtime(
true );
219 $timeDiff = $lang->formatTimePeriod( $time2 - $time1 );
220 $this->output(
"\nDone in $timeDiff.\n" );