X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Farchives%2FupgradeLogging.php;h=aeadc93d4db6a000c36919cd5f7e0a04c8befc79;hb=9964ca1a390c446397dcd466916ffed356cdc3c9;hp=0749bbf64b8a9a3aec7c36111585b125ad73fe0b;hpb=8734fe02b84c0fdd6fa53454b23ce9239b50dc75;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/archives/upgradeLogging.php b/maintenance/archives/upgradeLogging.php index 0749bbf64b..0beff7caec 100644 --- a/maintenance/archives/upgradeLogging.php +++ b/maintenance/archives/upgradeLogging.php @@ -32,14 +32,14 @@ require __DIR__ . '/../commandLine.inc'; class UpdateLogging { /** - * @var DatabaseBase + * @var Database */ public $dbw; public $batchSize = 1000; public $minTs = false; function execute() { - $this->dbw = wfGetDB( DB_MASTER ); + $this->dbw = $this->getDB( DB_MASTER ); $logging = $this->dbw->tableName( 'logging' ); $logging_1_10 = $this->dbw->tableName( 'logging_1_10' ); $logging_pre_1_10 = $this->dbw->tableName( 'logging_pre_1_10' ); @@ -52,6 +52,7 @@ class UpdateLogging { if ( $this->dbw->tableExists( 'logging_pre_1_10' ) ) { echo "This script has already been run to completion\n"; + return; } @@ -124,6 +125,8 @@ EOT; /** * Copy all rows from $srcTable to $dstTable + * @param string $srcTable + * @param string $dstTable */ function sync( $srcTable, $dstTable ) { $batchSize = 1000; @@ -153,17 +156,17 @@ EOT; if ( $copyPos === null ) { $conds = false; } else { - $conds = array( 'log_timestamp > ' . $this->dbw->addQuotes( $copyPos ) ); + $conds = [ 'log_timestamp > ' . $this->dbw->addQuotes( $copyPos ) ]; } $srcRes = $this->dbw->select( $srcTable, '*', $conds, __METHOD__, - array( 'LIMIT' => $batchSize, 'ORDER BY' => 'log_timestamp' ) ); + [ 'LIMIT' => $batchSize, 'ORDER BY' => 'log_timestamp' ] ); - if ( ! $srcRes->numRows() ) { + if ( !$srcRes->numRows() ) { # All done break; } - $batch = array(); + $batch = []; foreach ( $srcRes as $srcRow ) { $batch[] = (array)$srcRow; } @@ -177,18 +180,18 @@ EOT; function copyExactMatch( $srcTable, $dstTable, $copyPos ) { $numRowsCopied = 0; - $srcRes = $this->dbw->select( $srcTable, '*', array( 'log_timestamp' => $copyPos ), __METHOD__ ); - $dstRes = $this->dbw->select( $dstTable, '*', array( 'log_timestamp' => $copyPos ), __METHOD__ ); + $srcRes = $this->dbw->select( $srcTable, '*', [ 'log_timestamp' => $copyPos ], __METHOD__ ); + $dstRes = $this->dbw->select( $dstTable, '*', [ 'log_timestamp' => $copyPos ], __METHOD__ ); if ( $srcRes->numRows() ) { $srcRow = $srcRes->fetchObject(); $srcFields = array_keys( (array)$srcRow ); $srcRes->seek( 0 ); - $dstRowsSeen = array(); + $dstRowsSeen = []; # Make a hashtable of rows that already exist in the destination foreach ( $dstRes as $dstRow ) { - $reducedDstRow = array(); + $reducedDstRow = []; foreach ( $srcFields as $field ) { $reducedDstRow[$field] = $dstRow->$field; } @@ -205,6 +208,7 @@ EOT; } } } + return $numRowsCopied; } }