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-10-27 13:56:58 +00:00
|
|
|
* It is kept compatible with php 4 parsing so that it can give out a meaningful error.
|
2008-07-19 12:15:07 +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
|
|
|
|
|
*
|
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
|
|
|
|
2012-04-16 14:23:41 +00:00
|
|
|
if ( !function_exists( 'version_compare' ) || ( version_compare( phpversion(), '5.3.2' ) < 0 ) ) {
|
|
|
|
|
echo "You are using PHP version " . phpversion() . " but MediaWiki needs PHP 5.3.2 or higher. ABORTING.\n" .
|
2010-10-26 21:42:49 +00:00
|
|
|
"Check if you have a newer php executable with a different name, such as php5.\n";
|
|
|
|
|
die( 1 );
|
|
|
|
|
}
|
|
|
|
|
|
2005-08-20 01:57:32 +00:00
|
|
|
$wgUseMasterForMaintenance = true;
|
2012-08-27 19:03:15 +00:00
|
|
|
require_once( __DIR__ . '/Maintenance.php' );
|
2009-07-03 06:56:46 +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 {
|
2006-04-26 20:42:15 +00:00
|
|
|
|
2010-10-26 21:42:49 +00:00
|
|
|
function __construct() {
|
2010-09-07 14:33:11 +00:00
|
|
|
parent::__construct();
|
|
|
|
|
$this->mDescription = "MediaWiki database updater";
|
|
|
|
|
$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' );
|
|
|
|
|
$this->addOption( 'nopurge', 'Do not purge the objectcache table after updates' );
|
2011-11-03 20:15:27 +00:00
|
|
|
$this->addOption( 'force', 'Override when $wgAllowSchemaUpdates disables this script' );
|
2010-09-07 14:33:11 +00:00
|
|
|
}
|
2006-04-26 20:42:15 +00:00
|
|
|
|
2010-10-26 21:42:49 +00:00
|
|
|
function getDbType() {
|
2010-10-27 14:46:58 +00:00
|
|
|
/* If we used the class constant PHP4 would give a parser error here */
|
2010-10-27 13:56:58 +00:00
|
|
|
return 2 /* Maintenance::DB_ADMIN */;
|
2010-09-07 14:33:11 +00:00
|
|
|
}
|
2006-11-11 16:59:32 +00:00
|
|
|
|
2011-03-19 19:48:29 +00:00
|
|
|
function compatChecks() {
|
2010-11-06 22:16:19 +00:00
|
|
|
$test = new PhpXmlBugTester();
|
|
|
|
|
if ( !$test->ok ) {
|
2010-12-04 03:20:14 +00:00
|
|
|
$this->error(
|
2010-11-06 22:16:19 +00:00
|
|
|
"Your system has a combination of PHP and libxml2 versions which is buggy\n" .
|
|
|
|
|
"and can cause hidden data corruption in MediaWiki and other web apps.\n" .
|
|
|
|
|
"Upgrade to PHP 5.2.9 or later and libxml2 2.7.3 or later!\n" .
|
|
|
|
|
"ABORTING (see http://bugs.php.net/bug.php?id=45996).\n",
|
|
|
|
|
true );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$test = new PhpRefCallBugTester;
|
|
|
|
|
$test->execute();
|
|
|
|
|
if ( !$test->ok ) {
|
|
|
|
|
$ver = phpversion();
|
|
|
|
|
$this->error(
|
|
|
|
|
"PHP $ver is not compatible with MediaWiki due to a bug involving\n" .
|
|
|
|
|
"reference parameters to __call. Upgrade to PHP 5.3.2 or higher, or \n" .
|
|
|
|
|
"downgrade to PHP 5.3.0 to fix this.\n" .
|
|
|
|
|
"ABORTING (see http://bugs.php.net/bug.php?id=50394 for details)\n",
|
|
|
|
|
true );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-26 21:42:49 +00:00
|
|
|
function execute() {
|
2011-11-03 20:15:27 +00:00
|
|
|
global $wgVersion, $wgTitle, $wgLang, $wgAllowSchemaUpdates;
|
2011-07-13 22:14:19 +00:00
|
|
|
|
2011-11-03 20:17:49 +00:00
|
|
|
if( !$wgAllowSchemaUpdates && !$this->hasOption( 'force' ) ) {
|
2011-07-13 22:14:19 +00:00
|
|
|
$this->error( "Do not run update.php on this wiki. If you're seeing this you should\n"
|
|
|
|
|
. "probably ask for some help in performing your schema updates.\n\n"
|
2011-10-31 17:30:47 +00:00
|
|
|
. "If you know what you are doing, you can continue with --force", true );
|
2011-07-13 22:14:19 +00:00
|
|
|
}
|
2004-10-13 07:38:43 +00:00
|
|
|
|
2010-09-13 17:01:04 +00:00
|
|
|
$wgLang = Language::factory( 'en' );
|
2010-09-07 14:33:11 +00:00
|
|
|
$wgTitle = Title::newFromText( "MediaWiki database updater" );
|
2004-12-10 06:05:30 +00:00
|
|
|
|
2010-09-07 14:33:11 +00:00
|
|
|
$this->output( "MediaWiki {$wgVersion} Updater\n\n" );
|
2011-11-11 17:06:03 +00:00
|
|
|
|
2011-09-19 18:25:39 +00:00
|
|
|
wfWaitForSlaves( 5 ); // let's not kill databases, shall we? ;) --tor
|
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" );
|
|
|
|
|
wfCountdown( 5 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Attempt to connect to the database as a privileged user
|
|
|
|
|
# This will vomit up an error if there are permissions problems
|
|
|
|
|
$db = wfGetDB( DB_MASTER );
|
|
|
|
|
|
|
|
|
|
$this->output( "Going to run database updates for " . wfWikiID() . "\n" );
|
|
|
|
|
$this->output( "Depending on the size of your database this may take a while!\n" );
|
|
|
|
|
|
|
|
|
|
if ( !$this->hasOption( 'quick' ) ) {
|
|
|
|
|
$this->output( "Abort with control-c in the next five seconds (skip this countdown with --quick) ... " );
|
|
|
|
|
wfCountDown( 5 );
|
|
|
|
|
}
|
2004-12-10 06:05:30 +00:00
|
|
|
|
2010-09-07 14:33:11 +00:00
|
|
|
$shared = $this->hasOption( 'doshared' );
|
2011-03-30 20:56:03 +00:00
|
|
|
|
2011-09-03 10:23:47 +00:00
|
|
|
$updates = array( 'core', 'extensions', 'stats' );
|
2011-03-30 20:56:03 +00:00
|
|
|
if( !$this->hasOption('nopurge') ) {
|
|
|
|
|
$updates[] = 'purge';
|
|
|
|
|
}
|
2006-01-17 11:48:18 +00:00
|
|
|
|
2010-10-27 14:38:31 +00:00
|
|
|
$updater = DatabaseUpdater::newForDb( $db, $shared, $this );
|
2011-03-30 20:56:03 +00:00
|
|
|
$updater->doUpdates( $updates );
|
2004-10-13 07:38:43 +00:00
|
|
|
|
2010-09-07 14:33:11 +00:00
|
|
|
foreach( $updater->getPostDatabaseUpdateMaintenance() as $maint ) {
|
2011-11-11 17:06:03 +00:00
|
|
|
if ( $updater->updateRowExists( $maint ) ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2010-10-26 21:42:49 +00:00
|
|
|
$child = $this->runChild( $maint );
|
|
|
|
|
$child->execute();
|
2011-11-11 17:06:03 +00:00
|
|
|
$updater->insertUpdateRow( $maint );
|
2010-09-07 14:33:11 +00:00
|
|
|
}
|
|
|
|
|
|
2010-09-12 09:07:51 +00:00
|
|
|
$this->output( "\nDone.\n" );
|
2010-09-07 14:33:11 +00:00
|
|
|
}
|
2004-10-13 07:38:43 +00:00
|
|
|
|
2010-10-26 21:42:49 +00:00
|
|
|
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
|
2010-10-02 21:09:23 +00:00
|
|
|
# cache from $wgExtensionFunctions (bug 20471)
|
2010-09-07 20:45:04 +00:00
|
|
|
$wgLocalisationCacheConf = array(
|
|
|
|
|
'class' => 'LocalisationCache',
|
|
|
|
|
'storeClass' => 'LCStore_Null',
|
|
|
|
|
'storeDirectory' => false,
|
|
|
|
|
'manualRecache' => false,
|
|
|
|
|
);
|
|
|
|
|
}
|
2009-09-04 02:03:23 +00:00
|
|
|
}
|
2010-09-07 14:33:11 +00:00
|
|
|
|
|
|
|
|
$maintClass = 'UpdateMediaWiki';
|
2011-01-13 22:58:55 +00:00
|
|
|
require_once( RUN_MAINTENANCE_IF_MAIN );
|