X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FmigrateFileRepoLayout.php;h=536eddddb7f17a9b81ad43fa6f6620c8752015a9;hb=bb9e1c1aa906b3c6c2c19eb48c33b635dee6af20;hp=bd73f8b5752bd2c823c82ed13b45d3c2c3c4edd4;hpb=b5906606e1aa1a795231fb813b766818b1dd6c25;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/migrateFileRepoLayout.php b/maintenance/migrateFileRepoLayout.php index bd73f8b575..536eddddb7 100644 --- a/maintenance/migrateFileRepoLayout.php +++ b/maintenance/migrateFileRepoLayout.php @@ -43,11 +43,11 @@ class MigrateFileRepoLayout extends Maintenance { public function execute() { $oldLayout = $this->getOption( 'oldlayout' ); if ( !in_array( $oldLayout, [ 'name', 'sha1' ] ) ) { - $this->error( "Invalid old layout.", 1 ); + $this->fatalError( "Invalid old layout." ); } $newLayout = $this->getOption( 'newlayout' ); if ( !in_array( $newLayout, [ 'name', 'sha1' ] ) ) { - $this->error( "Invalid new layout.", 1 ); + $this->fatalError( "Invalid new layout." ); } $since = $this->getOption( 'since' ); @@ -69,6 +69,7 @@ class MigrateFileRepoLayout extends Maintenance { $conds[] = 'img_timestamp >= ' . $dbw->addQuotes( $dbw->timestamp( $since ) ); } + $batchSize = $this->getBatchSize(); $batch = []; $lastName = ''; do { @@ -76,7 +77,7 @@ class MigrateFileRepoLayout extends Maintenance { [ 'img_name', 'img_sha1' ], array_merge( [ 'img_name > ' . $dbw->addQuotes( $lastName ) ], $conds ), __METHOD__, - [ 'LIMIT' => $this->mBatchSize, 'ORDER BY' => 'img_name' ] + [ 'LIMIT' => $batchSize, 'ORDER BY' => 'img_name' ] ); foreach ( $res as $row ) { @@ -104,7 +105,7 @@ class MigrateFileRepoLayout extends Maintenance { $status = $be->prepare( [ 'dir' => dirname( $dpath ), 'bypassReadOnly' => 1 ] ); if ( !$status->isOK() ) { - $this->error( print_r( $status->getErrorsArray(), true ) ); + $this->error( print_r( $status->getErrors(), true ) ); } $batch[] = [ 'op' => 'copy', 'overwrite' => true, @@ -137,13 +138,13 @@ class MigrateFileRepoLayout extends Maintenance { $status = $be->prepare( [ 'dir' => dirname( $dpath ), 'bypassReadOnly' => 1 ] ); if ( !$status->isOK() ) { - $this->error( print_r( $status->getErrorsArray(), true ) ); + $this->error( print_r( $status->getErrors(), true ) ); } $batch[] = [ 'op' => 'copy', 'overwrite' => true, 'src' => $spath, 'dst' => $dpath, 'img' => $ofile->getArchiveName() ]; } - if ( count( $batch ) >= $this->mBatchSize ) { + if ( count( $batch ) >= $batchSize ) { $this->runBatch( $batch, $be ); $batch = []; } @@ -166,7 +167,7 @@ class MigrateFileRepoLayout extends Maintenance { $res = $dbw->select( 'filearchive', [ 'fa_storage_key', 'fa_id', 'fa_name' ], array_merge( [ 'fa_id > ' . $dbw->addQuotes( $lastId ) ], $conds ), __METHOD__, - [ 'LIMIT' => $this->mBatchSize, 'ORDER BY' => 'fa_id' ] + [ 'LIMIT' => $batchSize, 'ORDER BY' => 'fa_id' ] ); foreach ( $res as $row ) { @@ -195,13 +196,13 @@ class MigrateFileRepoLayout extends Maintenance { $status = $be->prepare( [ 'dir' => dirname( $dpath ), 'bypassReadOnly' => 1 ] ); if ( !$status->isOK() ) { - $this->error( print_r( $status->getErrorsArray(), true ) ); + $this->error( print_r( $status->getErrors(), true ) ); } $batch[] = [ 'op' => 'copy', 'src' => $spath, 'dst' => $dpath, 'overwriteSame' => true, 'img' => "(ID {$row->fa_id}) {$row->fa_name}" ]; - if ( count( $batch ) >= $this->mBatchSize ) { + if ( count( $batch ) >= $batchSize ) { $this->runBatch( $batch, $be ); $batch = []; } @@ -227,7 +228,7 @@ class MigrateFileRepoLayout extends Maintenance { $status = $be->doOperations( $ops, [ 'bypassReadOnly' => 1 ] ); if ( !$status->isOK() ) { - $this->output( print_r( $status->getErrorsArray(), true ) ); + $this->output( print_r( $status->getErrors(), true ) ); } $this->output( "Batch done\n\n" );