Convert all array() syntax to []
[lhc/web/wiklou.git] / includes / installer / DatabaseUpdater.php
index 61c3002..03f091b 100644 (file)
@@ -38,20 +38,20 @@ abstract class DatabaseUpdater {
         *
         * @var array
         */
-       protected $updates = array();
+       protected $updates = [];
 
        /**
         * Array of updates that were skipped
         *
         * @var array
         */
-       protected $updatesSkipped = array();
+       protected $updatesSkipped = [];
 
        /**
         * List of extension-provided database updates
         * @var array
         */
-       protected $extensionUpdates = array();
+       protected $extensionUpdates = [];
 
        /**
         * Handle to the database subclass
@@ -66,7 +66,7 @@ abstract class DatabaseUpdater {
         * Scripts to run after database update
         * Should be a subclass of LoggedUpdateMaintenance
         */
-       protected $postDatabaseUpdateMaintenance = array(
+       protected $postDatabaseUpdateMaintenance = [
                'DeleteDefaultMessages',
                'PopulateRevisionLength',
                'PopulateRevisionSha1',
@@ -75,7 +75,7 @@ abstract class DatabaseUpdater {
                'PopulateFilearchiveSha1',
                'PopulateBacklinkNamespace',
                'FixDefaultJsonContentPages'
-       );
+       ];
 
        /**
         * File handle for SQL output.
@@ -116,7 +116,7 @@ abstract class DatabaseUpdater {
                $this->maintenance->setDB( $db );
                $this->initOldGlobals();
                $this->loadExtensions();
-               Hooks::run( 'LoadExtensionSchemaUpdates', array( $this ) );
+               Hooks::run( 'LoadExtensionSchemaUpdates', [ $this ] );
        }
 
        /**
@@ -129,12 +129,12 @@ abstract class DatabaseUpdater {
 
                # For extensions only, should be populated via hooks
                # $wgDBtype should be checked to specifiy the proper file
-               $wgExtNewTables = array(); // table, dir
-               $wgExtNewFields = array(); // table, column, dir
-               $wgExtPGNewFields = array(); // table, column, column attributes; for PostgreSQL
-               $wgExtPGAlteredFields = array(); // table, column, new type, conversion method; for PostgreSQL
-               $wgExtNewIndexes = array(); // table, index, dir
-               $wgExtModifiedFields = array(); // table, index, dir
+               $wgExtNewTables = []; // table, dir
+               $wgExtNewFields = []; // table, column, dir
+               $wgExtPGNewFields = []; // table, column, column attributes; for PostgreSQL
+               $wgExtPGAlteredFields = []; // table, column, new type, conversion method; for PostgreSQL
+               $wgExtNewIndexes = []; // table, index, dir
+               $wgExtModifiedFields = []; // table, index, dir
        }
 
        /**
@@ -154,7 +154,7 @@ abstract class DatabaseUpdater {
 
                // This will automatically add "AutoloadClasses" to $wgAutoloadClasses
                $data = $registry->readFromQueue( $queue );
-               $hooks = array( 'wgHooks' => array( 'LoadExtensionSchemaUpdates' => array() ) );
+               $hooks = [ 'wgHooks' => [ 'LoadExtensionSchemaUpdates' => [] ] ];
                if ( isset( $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
                        $hooks = $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'];
                }
@@ -240,7 +240,7 @@ abstract class DatabaseUpdater {
         * @param string $sqlPath Full path to the schema file
         */
        public function addExtensionTable( $tableName, $sqlPath ) {
-               $this->extensionUpdates[] = array( 'addTable', $tableName, $sqlPath, true );
+               $this->extensionUpdates[] = [ 'addTable', $tableName, $sqlPath, true ];
        }
 
        /**
@@ -251,7 +251,7 @@ abstract class DatabaseUpdater {
         * @param string $sqlPath
         */
        public function addExtensionIndex( $tableName, $indexName, $sqlPath ) {
-               $this->extensionUpdates[] = array( 'addIndex', $tableName, $indexName, $sqlPath, true );
+               $this->extensionUpdates[] = [ 'addIndex', $tableName, $indexName, $sqlPath, true ];
        }
 
        /**
@@ -263,7 +263,7 @@ abstract class DatabaseUpdater {
         * @param string $sqlPath
         */
        public function addExtensionField( $tableName, $columnName, $sqlPath ) {
-               $this->extensionUpdates[] = array( 'addField', $tableName, $columnName, $sqlPath, true );
+               $this->extensionUpdates[] = [ 'addField', $tableName, $columnName, $sqlPath, true ];
        }
 
        /**
@@ -275,7 +275,7 @@ abstract class DatabaseUpdater {
         * @param string $sqlPath
         */
        public function dropExtensionField( $tableName, $columnName, $sqlPath ) {
-               $this->extensionUpdates[] = array( 'dropField', $tableName, $columnName, $sqlPath, true );
+               $this->extensionUpdates[] = [ 'dropField', $tableName, $columnName, $sqlPath, true ];
        }
 
        /**
@@ -288,7 +288,7 @@ abstract class DatabaseUpdater {
         * @param string $sqlPath The path to the SQL change path
         */
        public function dropExtensionIndex( $tableName, $indexName, $sqlPath ) {
-               $this->extensionUpdates[] = array( 'dropIndex', $tableName, $indexName, $sqlPath, true );
+               $this->extensionUpdates[] = [ 'dropIndex', $tableName, $indexName, $sqlPath, true ];
        }
 
        /**
@@ -299,7 +299,7 @@ abstract class DatabaseUpdater {
         * @param string $sqlPath
         */
        public function dropExtensionTable( $tableName, $sqlPath ) {
-               $this->extensionUpdates[] = array( 'dropTable', $tableName, $sqlPath, true );
+               $this->extensionUpdates[] = [ 'dropTable', $tableName, $sqlPath, true ];
        }
 
        /**
@@ -317,7 +317,7 @@ abstract class DatabaseUpdater {
        public function renameExtensionIndex( $tableName, $oldIndexName, $newIndexName,
                $sqlPath, $skipBothIndexExistWarning = false
        ) {
-               $this->extensionUpdates[] = array(
+               $this->extensionUpdates[] = [
                        'renameIndex',
                        $tableName,
                        $oldIndexName,
@@ -325,7 +325,7 @@ abstract class DatabaseUpdater {
                        $skipBothIndexExistWarning,
                        $sqlPath,
                        true
-               );
+               ];
        }
 
        /**
@@ -336,7 +336,7 @@ abstract class DatabaseUpdater {
         * @param string $sqlPath The path to the SQL change path
         */
        public function modifyExtensionField( $tableName, $fieldName, $sqlPath ) {
-               $this->extensionUpdates[] = array( 'modifyField', $tableName, $fieldName, $sqlPath, true );
+               $this->extensionUpdates[] = [ 'modifyField', $tableName, $fieldName, $sqlPath, true ];
        }
 
        /**
@@ -387,9 +387,9 @@ abstract class DatabaseUpdater {
         * Writes the schema updates desired to a file for the DB Admin to run.
         * @param array $schemaUpdate
         */
-       private function writeSchemaUpdateFile( $schemaUpdate = array() ) {
+       private function writeSchemaUpdateFile( $schemaUpdate = [] ) {
                $updates = $this->updatesSkipped;
-               $this->updatesSkipped = array();
+               $this->updatesSkipped = [];
 
                foreach ( $updates as $funcList ) {
                        $func = $funcList[0];
@@ -406,7 +406,7 @@ abstract class DatabaseUpdater {
         *
         * @param array $what What updates to perform
         */
-       public function doUpdates( $what = array( 'core', 'extensions', 'stats' ) ) {
+       public function doUpdates( $what = [ 'core', 'extensions', 'stats' ] ) {
                global $wgVersion;
 
                $this->db->begin( __METHOD__ );
@@ -442,13 +442,13 @@ abstract class DatabaseUpdater {
         * @param bool $passSelf Whether to pass this object we calling external functions
         */
        private function runUpdates( array $updates, $passSelf ) {
-               $updatesDone = array();
-               $updatesSkipped = array();
+               $updatesDone = [];
+               $updatesSkipped = [];
                foreach ( $updates as $params ) {
                        $origParams = $params;
                        $func = array_shift( $params );
                        if ( !is_array( $func ) && method_exists( $this, $func ) ) {
-                               $func = array( $this, $func );
+                               $func = [ $this, $func ];
                        } elseif ( $passSelf ) {
                                array_unshift( $params, $this );
                        }
@@ -458,7 +458,7 @@ abstract class DatabaseUpdater {
                                $updatesDone[] = $origParams;
                                wfGetLBFactory()->waitForReplication();
                        } else {
-                               $updatesSkipped[] = array( $func, $params, $origParams );
+                               $updatesSkipped[] = [ $func, $params, $origParams ];
                        }
                }
                $this->updatesSkipped = array_merge( $this->updatesSkipped, $updatesSkipped );
@@ -469,7 +469,7 @@ abstract class DatabaseUpdater {
         * @param string $version
         * @param array $updates
         */
-       protected function setAppliedUpdates( $version, $updates = array() ) {
+       protected function setAppliedUpdates( $version, $updates = [] ) {
                $this->db->clearFlag( DBO_DDLMODE );
                if ( !$this->canUseNewUpdatelog() ) {
                        return;
@@ -477,7 +477,7 @@ abstract class DatabaseUpdater {
                $key = "updatelist-$version-" . time() . self::$updateCounter;
                self::$updateCounter++;
                $this->db->insert( 'updatelog',
-                       array( 'ul_key' => $key, 'ul_value' => serialize( $updates ) ),
+                       [ 'ul_key' => $key, 'ul_value' => serialize( $updates ) ],
                        __METHOD__ );
                $this->db->setFlag( DBO_DDLMODE );
        }
@@ -494,7 +494,7 @@ abstract class DatabaseUpdater {
                        'updatelog',
                        # Bug 65813
                        '1 AS X',
-                       array( 'ul_key' => $key ),
+                       [ 'ul_key' => $key ],
                        __METHOD__
                );
 
@@ -510,7 +510,7 @@ abstract class DatabaseUpdater {
         */
        public function insertUpdateRow( $key, $val = null ) {
                $this->db->clearFlag( DBO_DDLMODE );
-               $values = array( 'ul_key' => $key );
+               $values = [ 'ul_key' => $key ];
                if ( $val && $this->canUseNewUpdatelog() ) {
                        $values['ul_value'] = $val;
                }
@@ -568,33 +568,33 @@ abstract class DatabaseUpdater {
                global $wgExtNewFields, $wgExtNewTables, $wgExtModifiedFields,
                        $wgExtNewIndexes;
 
-               $updates = array();
+               $updates = [];
 
                foreach ( $wgExtNewTables as $tableRecord ) {
-                       $updates[] = array(
+                       $updates[] = [
                                'addTable', $tableRecord[0], $tableRecord[1], true
-                       );
+                       ];
                }
 
                foreach ( $wgExtNewFields as $fieldRecord ) {
-                       $updates[] = array(
+                       $updates[] = [
                                'addField', $fieldRecord[0], $fieldRecord[1],
                                $fieldRecord[2], true
-                       );
+                       ];
                }
 
                foreach ( $wgExtNewIndexes as $fieldRecord ) {
-                       $updates[] = array(
+                       $updates[] = [
                                'addIndex', $fieldRecord[0], $fieldRecord[1],
                                $fieldRecord[2], true
-                       );
+                       ];
                }
 
                foreach ( $wgExtModifiedFields as $fieldRecord ) {
-                       $updates[] = array(
+                       $updates[] = [
                                'modifyField', $fieldRecord[0], $fieldRecord[1],
                                $fieldRecord[2], true
-                       );
+                       ];
                }
 
                return $updates;
@@ -617,7 +617,7 @@ abstract class DatabaseUpdater {
         */
        public function copyFile( $filename ) {
                $this->db->sourceFile( $filename, false, false, false,
-                       array( $this, 'appendLine' )
+                       [ $this, 'appendLine' ]
                );
        }
 
@@ -918,13 +918,13 @@ abstract class DatabaseUpdater {
        public function setFileAccess() {
                $repo = RepoGroup::singleton()->getLocalRepo();
                $zonePath = $repo->getZonePath( 'temp' );
-               if ( $repo->getBackend()->directoryExists( array( 'dir' => $zonePath ) ) ) {
+               if ( $repo->getBackend()->directoryExists( [ 'dir' => $zonePath ] ) ) {
                        // If the directory was never made, then it will have the right ACLs when it is made
-                       $status = $repo->getBackend()->secure( array(
+                       $status = $repo->getBackend()->secure( [
                                'dir' => $zonePath,
                                'noAccess' => true,
                                'noListing' => true
-                       ) );
+                       ] );
                        if ( $status->isOK() ) {
                                $this->output( "Set the local repo temp zone container to be private.\n" );
                        } else {
@@ -956,7 +956,7 @@ abstract class DatabaseUpdater {
         */
        protected function checkStats() {
                $this->output( "...site_stats is populated..." );
-               $row = $this->db->selectRow( 'site_stats', '*', array( 'ss_row_id' => 1 ), __METHOD__ );
+               $row = $this->db->selectRow( 'site_stats', '*', [ 'ss_row_id' => 1 ], __METHOD__ );
                if ( $row === false ) {
                        $this->output( "data is missing! rebuilding...\n" );
                } elseif ( isset( $row->site_stats ) && $row->ss_total_pages == -1 ) {
@@ -979,11 +979,11 @@ abstract class DatabaseUpdater {
                if ( $activeUsers == -1 ) {
                        $activeUsers = $this->db->selectField( 'recentchanges',
                                'COUNT( DISTINCT rc_user_text )',
-                               array( 'rc_user != 0', 'rc_bot' => 0, "rc_log_type != 'newusers'" ), __METHOD__
+                               [ 'rc_user != 0', 'rc_bot' => 0, "rc_log_type != 'newusers'" ], __METHOD__
                        );
                        $this->db->update( 'site_stats',
-                               array( 'ss_active_users' => intval( $activeUsers ) ),
-                               array( 'ss_row_id' => 1 ), __METHOD__, array( 'LIMIT' => 1 )
+                               [ 'ss_active_users' => intval( $activeUsers ) ],
+                               [ 'ss_row_id' => 1 ], __METHOD__, [ 'LIMIT' => 1 ]
                        );
                }
                $this->output( "...ss_active_users user count set...\n" );