X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2FpopulateImageSha1.php;h=5d6a19fb2f5e8c80143feedb770f1e1bb2854f06;hb=ce95625eef3203500a11314de3e77dae422762cc;hp=212a20de89b3080686bf5bfee94055ca26ef6dbb;hpb=77e3624caba072521fbc1826af2d47f9b29f4032;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/populateImageSha1.php b/maintenance/populateImageSha1.php index 212a20de89..5d6a19fb2f 100644 --- a/maintenance/populateImageSha1.php +++ b/maintenance/populateImageSha1.php @@ -21,6 +21,9 @@ * @ingroup Maintenance */ +use MediaWiki\MediaWikiServices; +use MediaWiki\Shell\Shell; + require_once __DIR__ . '/Maintenance.php'; /** @@ -106,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' . wfEscapeShellArg( $wgDBuser ) . - ' -h' . wfEscapeShellArg( $wgDBserver ) . - ' -p' . wfEscapeShellArg( $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' ); } @@ -123,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; } @@ -147,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 ) {