- $mPath = $this->substPaths( $path, $mBackend );
- $mSha1 = $mBackend->getFileSha1Base36( [ 'src' => $mPath, 'latest' => true ] );
- $mStat = $mBackend->getFileStat( [ 'src' => $mPath, 'latest' => true ] );
- if ( $mStat === null || ( $mSha1 !== false && !$mStat ) ) { // sanity
- $status->fatal( 'backend-fail-internal', $this->name );
- wfDebugLog( 'FileOperation', __METHOD__
- . ': File is not available on the master backend' );
- continue; // file is not available on the master backend...
+ $params = [ 'src' => $path, 'latest' => true ];
+ // Get the state of the file on the master backend
+ $masterBackend = $this->backends[$this->masterIndex];
+ $masterParams = $this->substOpPaths( $params, $masterBackend );
+ $masterPath = $masterParams['src'];
+ $masterStat = $masterBackend->getFileStat( $masterParams );
+ if ( $masterStat === self::STAT_ERROR ) {
+ $status->fatal( 'backend-fail-stat', $path );
+ $this->logger->error( "$fname: file '$masterPath' is not available" );
+ continue;
+ }
+ $masterSha1 = $masterBackend->getFileSha1Base36( $masterParams );
+ if ( ( $masterSha1 !== false ) !== (bool)$masterStat ) {
+ $status->fatal( 'backend-fail-hash', $path );
+ $this->logger->error( "$fname: file '$masterPath' hash does not match stat" );
+ continue;