X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=maintenance%2FpopulateImageSha1.php;h=5d6a19fb2f5e8c80143feedb770f1e1bb2854f06;hp=a71abb61ec7a5b6abe98ad9da7013ebd8e96cfd8;hb=54c93f1d384cd5accd2db2ebbb911e4d627c2980;hpb=7f2f49ad2368ae27f2d4db69b44c5f997197725e diff --git a/maintenance/populateImageSha1.php b/maintenance/populateImageSha1.php index a71abb61ec..5d6a19fb2f 100644 --- a/maintenance/populateImageSha1.php +++ b/maintenance/populateImageSha1.php @@ -21,6 +21,7 @@ * @ingroup Maintenance */ +use MediaWiki\MediaWikiServices; use MediaWiki\Shell\Shell; require_once __DIR__ . '/Maintenance.php'; @@ -108,10 +109,10 @@ class PopulateImageSha1 extends LoggedUpdateMaintenance { // with the database write operation, because the writes are queued // in the pipe buffer. This can improve performance by up to a // factor of 2. - global $wgDBuser, $wgDBserver, $wgDBpassword, $wgDBname; - $cmd = 'mysql -u' . Shell::escape( $wgDBuser ) . - ' -h' . Shell::escape( $wgDBserver ) . - ' -p' . Shell::escape( $wgDBpassword, $wgDBname ); + $config = $this->getConfig(); + $cmd = 'mysql -u' . Shell::escape( $config->get( 'DBuser' ) ) . + ' -h' . Shell::escape( $config->get( 'DBserver' ) ) . + ' -p' . Shell::escape( $config->get( 'DBpassword' ), $config->get( 'DBname' ) ); $this->output( "Using pipe method\n" ); $pipe = popen( $cmd, 'w' ); } @@ -125,7 +126,8 @@ class PopulateImageSha1 extends LoggedUpdateMaintenance { wfWaitForSlaves(); } - $file = wfLocalFile( $row->img_name ); + $file = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo() + ->newFile( $row->img_name ); if ( !$file ) { continue; } @@ -149,6 +151,8 @@ class PopulateImageSha1 extends LoggedUpdateMaintenance { } // Upgrade the old file versions... foreach ( $file->getHistory() as $oldFile ) { + /** @var OldLocalFile $oldFile */ + '@phan-var OldLocalFile $oldFile'; $sha1 = $oldFile->getRepo()->getFileSha1( $oldFile->getPath() ); if ( strval( $sha1 ) !== '' ) { // file on disk and hashed properly if ( $isRegen && $oldFile->getSha1() !== $sha1 ) {