phpcs: More require/include is not a function
[lhc/web/wiklou.git] / maintenance / update.php
index 159b6b7..6fcec2c 100644 (file)
  */
 
 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" .
-       "Check if you have a newer php executable with a different name, such as php5.\n";
-       die( 1 );
+       require dirname( __FILE__ ) . '/../includes/PHPVersionError.php';
+       wfPHPVersionError( 'cli' );
 }
 
 $wgUseMasterForMaintenance = true;
-require_once( __DIR__ . '/Maintenance.php' );
+require_once __DIR__ . '/Maintenance.php';
 
 /**
  * Maintenance script to run database schema updates.
@@ -84,7 +83,7 @@ class UpdateMediaWiki extends Maintenance {
        function execute() {
                global $wgVersion, $wgTitle, $wgLang, $wgAllowSchemaUpdates;
 
-               if( !$wgAllowSchemaUpdates && !( $this->hasOption( 'force' ) || $this->hasOption( 'schema' ) || $this->hasOption( 'noschema' ) ) ) {
+               if ( !$wgAllowSchemaUpdates && !( $this->hasOption( 'force' ) || $this->hasOption( 'schema' ) || $this->hasOption( 'noschema' ) ) ) {
                        $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 or use\n"
                                . "the --noschema and --schema options to get an SQL file for someone\n"
@@ -93,12 +92,12 @@ class UpdateMediaWiki extends Maintenance {
                }
 
                $this->fileHandle = null;
-               if( substr( $this->getOption( 'schema' ), 0, 2 ) === "--" ) {
+               if ( substr( $this->getOption( 'schema' ), 0, 2 ) === "--" ) {
                        $this->error( "The --schema option requires a file as an argument.\n", true );
-               } else if( $this->hasOption( 'schema' ) ) {
+               } elseif ( $this->hasOption( 'schema' ) ) {
                        $file = $this->getOption( 'schema' );
                        $this->fileHandle = fopen( $file, "w" );
-                       if( $this->fileHandle === false ) {
+                       if ( $this->fileHandle === false ) {
                                $err = error_get_last();
                                $this->error( "Problem opening the schema file for writing: $file\n\t{$err['message']}", true );
                        }
@@ -123,7 +122,7 @@ class UpdateMediaWiki extends Maintenance {
                $db = wfGetDB( DB_MASTER );
 
                $this->output( "Going to run database updates for " . wfWikiID() . "\n" );
-               if( $db->getType() === 'sqlite' ) {
+               if ( $db->getType() === 'sqlite' ) {
                        $this->output( "Using SQLite file: '{$db->mDatabaseFile}'\n" );
                }
                $this->output( "Depending on the size of your database this may take a while!\n" );
@@ -136,13 +135,13 @@ class UpdateMediaWiki extends Maintenance {
                $shared = $this->hasOption( 'doshared' );
 
                $updates = array( 'core', 'extensions' );
-               if( !$this->hasOption('schema') ) {
-                       if( $this->hasOption('noschema') ) {
+               if ( !$this->hasOption( 'schema' ) ) {
+                       if ( $this->hasOption( 'noschema' ) ) {
                                $updates[] = 'noschema';
                        }
                        $updates[] = 'stats';
 
-                       if( !$this->hasOption('nopurge') ) {
+                       if ( !$this->hasOption( 'nopurge' ) ) {
                                $updates[] = 'purge';
                        }
                }
@@ -150,7 +149,7 @@ class UpdateMediaWiki extends Maintenance {
                $updater = DatabaseUpdater::newForDb( $db, $shared, $this );
                $updater->doUpdates( $updates );
 
-               foreach( $updater->getPostDatabaseUpdateMaintenance() as $maint ) {
+               foreach ( $updater->getPostDatabaseUpdateMaintenance() as $maint ) {
                        $child = $this->runChild( $maint );
 
                        // LoggedUpdateMaintenance is checking the updatelog itself
@@ -167,7 +166,7 @@ class UpdateMediaWiki extends Maintenance {
                        }
                }
 
-               if( !$this->hasOption('nopurge') ) {
+               if ( !$this->hasOption( 'nopurge' ) ) {
                        $updater->purgeCache();
                }
 
@@ -190,4 +189,4 @@ class UpdateMediaWiki extends Maintenance {
 }
 
 $maintClass = 'UpdateMediaWiki';
-require_once( RUN_MAINTENANCE_IF_MAIN );
+require_once RUN_MAINTENANCE_IF_MAIN;