Try to fix some other broken-looking legacy maintenance script options
[lhc/web/wiklou.git] / maintenance / storage / trackBlobs.php
index a3f9386..214f5b1 100644 (file)
@@ -38,7 +38,7 @@ echo "All done.\n";
 class TrackBlobs {
        public $clusters, $textClause;
        public $doBlobOrphans;
-       public $trackedBlobs = array();
+       public $trackedBlobs = [];
 
        public $batchSize = 1000;
        public $reportingInterval = 10;
@@ -135,11 +135,11 @@ class TrackBlobs {
                        return false;
                }
 
-               return array(
+               return [
                        'cluster' => $m[1],
                        'id' => intval( $m[2] ),
                        'hash' => isset( $m[3] ) ? $m[3] : null
-               );
+               ];
        }
 
        /**
@@ -158,25 +158,25 @@ class TrackBlobs {
                echo "Finding revisions...\n";
 
                while ( true ) {
-                       $res = $dbr->select( array( 'revision', 'text' ),
-                               array( 'rev_id', 'rev_page', 'old_id', 'old_flags', 'old_text' ),
-                               array(
+                       $res = $dbr->select( [ 'revision', 'text' ],
+                               [ 'rev_id', 'rev_page', 'old_id', 'old_flags', 'old_text' ],
+                               [
                                        'rev_id > ' . $dbr->addQuotes( $startId ),
                                        'rev_text_id=old_id',
                                        $textClause,
                                        'old_flags ' . $dbr->buildLike( $dbr->anyString(), 'external', $dbr->anyString() ),
-                               ),
+                               ],
                                __METHOD__,
-                               array(
+                               [
                                        'ORDER BY' => 'rev_id',
                                        'LIMIT' => $this->batchSize
-                               )
+                               ]
                        );
                        if ( !$res->numRows() ) {
                                break;
                        }
 
-                       $insertBatch = array();
+                       $insertBatch = [];
                        foreach ( $res as $row ) {
                                $startId = $row->rev_id;
                                $info = $this->interpretPointer( $row->old_text );
@@ -188,14 +188,14 @@ class TrackBlobs {
                                        echo "Invalid cluster returned in SQL query: {$info['cluster']}\n";
                                        continue;
                                }
-                               $insertBatch[] = array(
+                               $insertBatch[] = [
                                        'bt_page' => $row->rev_page,
                                        'bt_rev_id' => $row->rev_id,
                                        'bt_text_id' => $row->old_id,
                                        'bt_cluster' => $info['cluster'],
                                        'bt_blob_id' => $info['id'],
                                        'bt_cgz_hash' => $info['hash']
-                               );
+                               ];
                                if ( $this->doBlobOrphans ) {
                                        gmp_setbit( $this->trackedBlobs[$info['cluster']], $info['id'] );
                                }
@@ -235,22 +235,22 @@ class TrackBlobs {
 
                # Scan the text table for orphan text
                while ( true ) {
-                       $res = $dbr->select( array( 'text', 'blob_tracking' ),
-                               array( 'old_id', 'old_flags', 'old_text' ),
-                               array(
+                       $res = $dbr->select( [ 'text', 'blob_tracking' ],
+                               [ 'old_id', 'old_flags', 'old_text' ],
+                               [
                                        'old_id>' . $dbr->addQuotes( $startId ),
                                        $textClause,
                                        'old_flags ' . $dbr->buildLike( $dbr->anyString(), 'external', $dbr->anyString() ),
                                        'bt_text_id IS NULL'
-                               ),
+                               ],
                                __METHOD__,
-                               array(
+                               [
                                        'ORDER BY' => 'old_id',
                                        'LIMIT' => $this->batchSize
-                               ),
-                               array( 'blob_tracking' => array( 'LEFT JOIN', 'bt_text_id=old_id' ) )
+                               ],
+                               [ 'blob_tracking' => [ 'LEFT JOIN', 'bt_text_id=old_id' ] ]
                        );
-                       $ids = array();
+                       $ids = [];
                        foreach ( $res as $row ) {
                                $ids[] = $row->old_id;
                        }
@@ -259,7 +259,7 @@ class TrackBlobs {
                                break;
                        }
 
-                       $insertBatch = array();
+                       $insertBatch = [];
                        foreach ( $res as $row ) {
                                $startId = $row->old_id;
                                $info = $this->interpretPointer( $row->old_text );
@@ -272,14 +272,14 @@ class TrackBlobs {
                                        continue;
                                }
 
-                               $insertBatch[] = array(
+                               $insertBatch[] = [
                                        'bt_page' => 0,
                                        'bt_rev_id' => 0,
                                        'bt_text_id' => $row->old_id,
                                        'bt_cluster' => $info['cluster'],
                                        'bt_blob_id' => $info['id'],
                                        'bt_cgz_hash' => $info['hash']
-                               );
+                               ];
                                if ( $this->doBlobOrphans ) {
                                        gmp_setbit( $this->trackedBlobs[$info['cluster']], $info['id'] );
                                }
@@ -342,10 +342,10 @@ class TrackBlobs {
                        // Build a bitmap of actual blob rows
                        while ( true ) {
                                $res = $extDB->select( $table,
-                                       array( 'blob_id' ),
-                                       array( 'blob_id > ' . $extDB->addQuotes( $startId ) ),
+                                       [ 'blob_id' ],
+                                       [ 'blob_id > ' . $extDB->addQuotes( $startId ) ],
                                        __METHOD__,
-                                       array( 'LIMIT' => $this->batchSize, 'ORDER BY' => 'blob_id' )
+                                       [ 'LIMIT' => $this->batchSize, 'ORDER BY' => 'blob_id' ]
                                );
 
                                if ( !$res->numRows() ) {
@@ -369,7 +369,7 @@ class TrackBlobs {
                        $orphans = gmp_and( $actualBlobs, gmp_com( $this->trackedBlobs[$cluster] ) );
 
                        // Traverse the orphan list
-                       $insertBatch = array();
+                       $insertBatch = [];
                        $id = 0;
                        $numOrphans = 0;
                        while ( true ) {
@@ -377,13 +377,13 @@ class TrackBlobs {
                                if ( $id == -1 ) {
                                        break;
                                }
-                               $insertBatch[] = array(
+                               $insertBatch[] = [
                                        'bo_cluster' => $cluster,
                                        'bo_blob_id' => $id
-                               );
+                               ];
                                if ( count( $insertBatch ) > $this->batchSize ) {
                                        $dbw->insert( 'blob_orphans', $insertBatch, __METHOD__ );
-                                       $insertBatch = array();
+                                       $insertBatch = [];
                                }
 
                                ++$id;