Merge "Fixup contenttype stuff in UserMailer"
[lhc/web/wiklou.git] / maintenance / storage / compressOld.php
index b27b111..ba924bf 100644 (file)
@@ -63,7 +63,7 @@ class CompressOld extends Maintenance {
 
        public function __construct() {
                parent::__construct();
-               $this->mDescription = 'Compress the text of a wiki';
+               $this->addDescription( 'Compress the text of a wiki' );
                $this->addOption( 'type', 'Set compression type to either: gzip|concat', false, true, 't' );
                $this->addOption(
                        'chunksize',
@@ -155,10 +155,10 @@ class CompressOld extends Maintenance {
                do {
                        $res = $dbw->select(
                                'text',
-                               array( 'old_id', 'old_flags', 'old_text' ),
+                               [ 'old_id', 'old_flags', 'old_text' ],
                                "old_id>=$start",
                                __METHOD__,
-                               array( 'ORDER BY' => 'old_id', 'LIMIT' => $chunksize, 'FOR UPDATE' )
+                               [ 'ORDER BY' => 'old_id', 'LIMIT' => $chunksize, 'FOR UPDATE' ]
                        );
 
                        if ( $res->numRows() == 0 ) {
@@ -209,13 +209,13 @@ class CompressOld extends Maintenance {
 
                # Update text row
                $dbw->update( 'text',
-                       array( /* SET */
+                       [ /* SET */
                                'old_flags' => $flags,
                                'old_text' => $compress
-                       ), array( /* WHERE */
+                       ], [ /* WHERE */
                                'old_id' => $row->old_id
-                       ), __METHOD__,
-                       array( 'LIMIT' => 1 )
+                       ], __METHOD__,
+                       [ 'LIMIT' => 1 ]
                );
 
                return true;
@@ -250,7 +250,7 @@ class CompressOld extends Maintenance {
                        $maxPageId = $dbr->selectField( 'page', 'max(page_id)', '', __METHOD__ );
                }
                $this->output( "Starting from $startId of $maxPageId\n" );
-               $pageConds = array();
+               $pageConds = [];
 
                /*
                if ( $exclude_ns0 ) {
@@ -268,11 +268,11 @@ class CompressOld extends Maintenance {
                # Don't compress object type entities, because that might produce data loss when
                # overwriting bulk storage concat rows. Don't compress external references, because
                # the script doesn't yet delete rows from external storage.
-               $conds = array(
+               $conds = [
                        'old_flags NOT ' . $dbr->buildLike( $dbr->anyString(), 'object', $dbr->anyString() )
                        . ' AND old_flags NOT '
                        . $dbr->buildLike( $dbr->anyString(), 'external', $dbr->anyString() )
-               );
+               ];
 
                if ( $beginDate ) {
                        if ( !preg_match( '/^\d{14}$/', $beginDate ) ) {
@@ -291,14 +291,14 @@ class CompressOld extends Maintenance {
                        $conds[] = "rev_timestamp<'" . $endDate . "'";
                }
                if ( $loadStyle == self::LS_CHUNKED ) {
-                       $tables = array( 'revision', 'text' );
-                       $fields = array( 'rev_id', 'rev_text_id', 'old_flags', 'old_text' );
+                       $tables = [ 'revision', 'text' ];
+                       $fields = [ 'rev_id', 'rev_text_id', 'old_flags', 'old_text' ];
                        $conds[] = 'rev_text_id=old_id';
                        $revLoadOptions = 'FOR UPDATE';
                } else {
-                       $tables = array( 'revision' );
-                       $fields = array( 'rev_id', 'rev_text_id' );
-                       $revLoadOptions = array();
+                       $tables = [ 'revision' ];
+                       $fields = [ 'rev_id', 'rev_text_id' ];
+                       $revLoadOptions = [];
                }
 
                # Don't work with current revisions
@@ -314,8 +314,8 @@ class CompressOld extends Maintenance {
 
                        # Get the page row
                        $pageRes = $dbr->select( 'page',
-                               array( 'page_id', 'page_namespace', 'page_title', 'page_latest' ),
-                               $pageConds + array( 'page_id' => $pageId ), __METHOD__ );
+                               [ 'page_id', 'page_namespace', 'page_title', 'page_latest' ],
+                               $pageConds + [ 'page_id' => $pageId ], __METHOD__ );
                        if ( $pageRes->numRows() == 0 ) {
                                continue;
                        }
@@ -327,17 +327,17 @@ class CompressOld extends Maintenance {
 
                        # Load revisions
                        $revRes = $dbw->select( $tables, $fields,
-                               array_merge( array(
+                               array_merge( [
                                        'rev_page' => $pageRow->page_id,
                                        # Don't operate on the current revision
                                        # Use < instead of <> in case the current revision has changed
                                        # since the page select, which wasn't locking
                                        'rev_id < ' . $pageRow->page_latest
-                               ), $conds ),
+                               ], $conds ),
                                __METHOD__,
                                $revLoadOptions
                        );
-                       $revs = array();
+                       $revs = [];
                        foreach ( $revRes as $revRow ) {
                                $revs[] = $revRow;
                        }
@@ -358,7 +358,7 @@ class CompressOld extends Maintenance {
                                }
 
                                $chunk = new ConcatenatedGzipHistoryBlob();
-                               $stubs = array();
+                               $stubs = [];
                                $this->beginTransaction( $dbw, __METHOD__ );
                                $usedChunk = false;
                                $primaryOldid = $revs[$i]->rev_text_id;
@@ -372,8 +372,8 @@ class CompressOld extends Maintenance {
                                        # Get text
                                        if ( $loadStyle == self::LS_INDIVIDUAL ) {
                                                $textRow = $dbw->selectRow( 'text',
-                                                       array( 'old_flags', 'old_text' ),
-                                                       array( 'old_id' => $oldid ),
+                                                       [ 'old_flags', 'old_text' ],
+                                                       [ 'old_id' => $oldid ],
                                                        __METHOD__,
                                                        'FOR UPDATE'
                                                );
@@ -426,23 +426,23 @@ class CompressOld extends Maintenance {
                                                        # $stored should provide base path to a BLOB
                                                        $url = $stored . "/" . $stub->getHash();
                                                        $dbw->update( 'text',
-                                                               array( /* SET */
+                                                               [ /* SET */
                                                                        'old_text' => $url,
                                                                        'old_flags' => 'external,utf-8',
-                                                               ), array( /* WHERE */
+                                                               ], [ /* WHERE */
                                                                        'old_id' => $stub->getReferrer(),
-                                                               )
+                                                               ]
                                                        );
                                                }
                                        } else {
                                                # Store the main object locally
                                                $dbw->update( 'text',
-                                                       array( /* SET */
+                                                       [ /* SET */
                                                                'old_text' => serialize( $chunk ),
                                                                'old_flags' => 'object,utf-8',
-                                                       ), array( /* WHERE */
+                                                       ], [ /* WHERE */
                                                                'old_id' => $primaryOldid
-                                                       )
+                                                       ]
                                                );
 
                                                # Store the stub objects
@@ -450,12 +450,12 @@ class CompressOld extends Maintenance {
                                                        # Skip if not compressing and don't overwrite the first revision
                                                        if ( $stubs[$j] !== false && $revs[$i + $j]->rev_text_id != $primaryOldid ) {
                                                                $dbw->update( 'text',
-                                                                       array( /* SET */
+                                                                       [ /* SET */
                                                                                'old_text' => serialize( $stubs[$j] ),
                                                                                'old_flags' => 'object,utf-8',
-                                                                       ), array( /* WHERE */
+                                                                       ], [ /* WHERE */
                                                                                'old_id' => $revs[$i + $j]->rev_text_id
-                                                                       )
+                                                                       ]
                                                                );
                                                        }
                                                }