Go to the documentation of this file.
28 if ( !function_exists(
'version_compare' ) || ( version_compare( phpversion(),
'5.3.2' ) < 0 ) ) {
29 require dirname( __FILE__ ) .
'/../includes/PHPVersionError.php';
34 require_once __DIR__ .
'/Maintenance.php';
43 parent::__construct();
44 $this->mDescription =
"MediaWiki database updater";
45 $this->
addOption(
'skip-compat-checks',
'Skips compatibility checks, mostly for developers' );
46 $this->
addOption(
'quick',
'Skip 5 second countdown before starting' );
47 $this->
addOption(
'doshared',
'Also update shared tables' );
48 $this->
addOption(
'nopurge',
'Do not purge the objectcache table after updates' );
49 $this->
addOption(
'noschema',
'Only do the updates that are not done during schema updates' );
50 $this->
addOption(
'schema',
'Output SQL to do the schema updates instead of doing them. Works even when $wgAllowSchemaUpdates is false',
false,
true );
51 $this->
addOption(
'force',
'Override when $wgAllowSchemaUpdates disables this script' );
61 $minimumPcreVersion = constant(
'Installer::MINIMUM_PCRE_VERSION' );
63 list( $pcreVersion ) = explode(
' ', PCRE_VERSION, 2 );
64 if ( version_compare( $pcreVersion, $minimumPcreVersion,
'<' ) ) {
66 "PCRE $minimumPcreVersion or later is required.\n" .
67 "Your PHP binary is linked with PCRE $pcreVersion.\n\n" .
68 "More information:\n" .
69 "https://www.mediawiki.org/wiki/Manual:Errors_and_symptoms/PCRE\n\n" .
77 "Your system has a combination of PHP and libxml2 versions that is buggy\n" .
78 "and can cause hidden data corruption in MediaWiki and other web apps.\n" .
79 "Upgrade to libxml2 2.7.3 or later.\n" .
80 "ABORTING (see https://bugs.php.net/bug.php?id=45996).\n",
88 if ( !$wgAllowSchemaUpdates && !( $this->
hasOption(
'force' ) || $this->
hasOption(
'schema' ) || $this->
hasOption(
'noschema' ) ) ) {
89 $this->
error(
"Do not run update.php on this wiki. If you're seeing this you should\n"
90 .
"probably ask for some help in performing your schema updates or use\n"
91 .
"the --noschema and --schema options to get an SQL file for someone\n"
92 .
"else to inspect and run.\n\n"
93 .
"If you know what you are doing, you can continue with --force\n",
true );
96 $this->fileHandle =
null;
97 if ( substr( $this->
getOption(
'schema' ), 0, 2 ) ===
"--" ) {
98 $this->
error(
"The --schema option requires a file as an argument.\n",
true );
99 } elseif ( $this->
hasOption(
'schema' ) ) {
101 $this->fileHandle = fopen(
$file,
"w" );
102 if ( $this->fileHandle ===
false ) {
103 $err = error_get_last();
104 $this->
error(
"Problem opening the schema file for writing: $file\n\t{$err['message']}",
true );
110 define(
'MW_UPDATER',
true );
112 $this->
output(
"MediaWiki {$wgVersion} Updater\n\n" );
116 if ( !$this->
hasOption(
'skip-compat-checks' ) ) {
119 $this->
output(
"Skipping compatibility checks, proceed at your own risk (Ctrl+C to abort)\n" );
123 # Attempt to connect to the database as a privileged user
124 # This will vomit up an error if there are permissions problems
127 $this->
output(
"Going to run database updates for " .
wfWikiID() .
"\n" );
128 if ( $db->getType() ===
'sqlite' ) {
129 $this->
output(
"Using SQLite file: '{$db->mDatabaseFile}'\n" );
131 $this->
output(
"Depending on the size of your database this may take a while!\n" );
134 $this->
output(
"Abort with control-c in the next five seconds (skip this countdown with --quick) ... " );
140 $shared = $this->
hasOption(
'doshared' );
142 $updates =
array(
'core',
'extensions' );
145 $updates[] =
'noschema';
147 $updates[] =
'stats';
150 $updater = DatabaseUpdater::newForDb( $db, $shared, $this );
151 $updater->doUpdates( $updates );
153 foreach ( $updater->getPostDatabaseUpdateMaintenance()
as $maint ) {
157 $isLoggedUpdate = is_a( $child,
'LoggedUpdateMaintenance' );
159 if ( !$isLoggedUpdate && $updater->updateRowExists( $maint ) ) {
164 if ( !$isLoggedUpdate ) {
165 $updater->insertUpdateRow( $maint );
170 $updater->purgeCache();
174 $timeDiff = $time2->diff( $time1 );
175 $this->
output(
"\nDone in " . $timeDiff->format(
"%i:%S" ) .
".\n" );
179 global $wgLocalisationCacheConf;
181 # Don't try to access the database
182 # This needs to be disabled early since extensions will try to use the l10n
183 # cache from $wgExtensionFunctions (bug 20471)
184 $wgLocalisationCacheConf =
array(
185 'class' =>
'LocalisationCache',
186 'storeClass' =>
'LCStoreNull',
187 'storeDirectory' =>
false,
188 'manualRecache' =>
false,
Library for creating and parsing MW-style timestamps.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
runChild( $maintClass, $classFile=null)
Run a child maintenance script.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
wfPHPVersionError( $type)
Display something vaguely comprehensible in the event of a totally unrecoverable error.
require_once RUN_MAINTENANCE_IF_MAIN
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
if(!function_exists( 'version_compare')||(version_compare(phpversion(), '5.3.2')< 0)) $wgUseMasterForMaintenance
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
wfWaitForSlaves( $maxLag=false, $wiki=false, $cluster=false)
Modern version of wfWaitForSlaves().
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
if(PHP_SAPI !='cli') $file
Test for PHP+libxml2 bug which breaks XML input subtly with certain versions.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
getOption( $name, $default=null)
Get an option, or return the default.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
static factory( $code)
Get a cached or new language object for a given language code.
hasOption( $name)
Checks to see if a particular param exists.
wfCountDown( $seconds)
Count down from $seconds to zero on the terminal, with a one-second pause between showing each number...