*/
protected $permMgr;
+ /**
+ * @var RepoGroup
+ */
+ protected $repoGroup;
+
/**
* Calling this directly is deprecated in 1.34. Use MovePageFactory instead.
*
LoadBalancer $loadBalancer = null,
NamespaceInfo $nsInfo = null,
WatchedItemStore $watchedItems = null,
- PermissionManager $permMgr = null
+ PermissionManager $permMgr = null,
+ RepoGroup $repoGroup = null
) {
$this->oldTitle = $oldTitle;
$this->newTitle = $newTitle;
$this->watchedItems =
$watchedItems ?? MediaWikiServices::getInstance()->getWatchedItemStore();
$this->permMgr = $permMgr ?? MediaWikiServices::getInstance()->getPermissionManager();
+ $this->repoGroup = $repoGroup ?? MediaWikiServices::getInstance()->getRepoGroup();
}
/**
*/
protected function isValidFileMove() {
$status = new Status();
- $file = wfLocalFile( $this->oldTitle );
+ $file = $this->repoGroup->getLocalRepo()->newFile( $this->oldTitle );
$file->load( File::READ_LATEST );
if ( $file->exists() ) {
if ( $this->newTitle->getText() != wfStripIllegalFilenameChars( $this->newTitle->getText() ) ) {
protected function isValidMoveTarget() {
# Is it an existing file?
if ( $this->newTitle->inNamespace( NS_FILE ) ) {
- $file = wfLocalFile( $this->newTitle );
+ $file = $this->repoGroup->getLocalRepo()->newFile( $this->newTitle );
$file->load( File::READ_LATEST );
if ( $file->exists() ) {
wfDebug( __METHOD__ . ": file exists\n" );
$oldTitle->getPrefixedText()
);
- $file = wfLocalFile( $oldTitle );
+ $file = $this->repoGroup->getLocalRepo()->newFile( $oldTitle );
$file->load( File::READ_LATEST );
if ( $file->exists() ) {
$status = $file->move( $newTitle );
}
// Clear RepoGroup process cache
- RepoGroup::singleton()->clearCache( $oldTitle );
- RepoGroup::singleton()->clearCache( $newTitle ); # clear false negative cache
+ $this->repoGroup->clearCache( $oldTitle );
+ $this->repoGroup->clearCache( $newTitle ); # clear false negative cache
return $status;
}
$services->getDBLoadBalancer(),
$services->getNamespaceInfo(),
$services->getWatchedItemStore(),
- $services->getPermissionManager()
+ $services->getPermissionManager(),
+ $services->getRepoGroup()
);
},
use MediaWiki\Permissions\PermissionManager;
use MovePage;
use NamespaceInfo;
+use RepoGroup;
use Title;
use WatchedItemStore;
use Wikimedia\Rdbms\LoadBalancer;
/** @var PermissionManager */
private $permMgr;
+ /** @var RepoGroup */
+ private $repoGroup;
+
/**
* @todo Make this a const when we drop HHVM support (T192166)
* @var array
LoadBalancer $loadBalancer,
NamespaceInfo $nsInfo,
WatchedItemStore $watchedItems,
- PermissionManager $permMgr
+ PermissionManager $permMgr,
+ RepoGroup $repoGroup
) {
$options->assertRequiredOptions( self::$constructorOptions );
$this->nsInfo = $nsInfo;
$this->watchedItems = $watchedItems;
$this->permMgr = $permMgr;
+ $this->repoGroup = $repoGroup;
}
/**
*/
public function newMovePage( Title $from, Title $to ) : MovePage {
return new MovePage( $from, $to, $this->options, $this->loadBalancer, $this->nsInfo,
- $this->watchedItems, $this->permMgr );
+ $this->watchedItems, $this->permMgr, $this->repoGroup );
}
}
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Page\MovePageFactory;
+use MediaWiki\Permissions\PermissionManager;
use Wikimedia\Rdbms\IDatabase;
use Wikimedia\Rdbms\LoadBalancer;
/**
* @param LinkTarget $old
* @param LinkTarget $new
- * @param array $params Valid keys are: db, options, nsInfo, wiStore. options is an indexed
- * array that will overwrite our defaults, not a ServiceOptions, so it need not contain all
- * keys.
+ * @param array $params Valid keys are: db, options, nsInfo, wiStore, repoGroup.
+ * options is an indexed array that will overwrite our defaults, not a ServiceOptions, so it
+ * need not contain all keys.
* @return MovePage
*/
private function newMovePage( $old, $new, array $params = [] ) : MovePage {
$mockLB->expects( $this->never() )
->method( $this->anythingBut( 'getConnection', '__destruct' ) );
+ $mockLocalFile = $this->createMock( LocalFile::class );
+ $mockLocalFile->method( 'exists' )->willReturn( false );
+ $mockLocalFile->expects( $this->never() )
+ ->method( $this->anythingBut( 'exists', 'load', '__destruct' ) );
+
+ $mockLocalRepo = $this->createMock( LocalRepo::class );
+ $mockLocalRepo->method( 'newFile' )->willReturn( $mockLocalFile );
+ $mockLocalRepo->expects( $this->never() )
+ ->method( $this->anythingBut( 'newFile', '__destruct' ) );
+
+ $mockRepoGroup = $this->createMock( RepoGroup::class );
+ $mockRepoGroup->method( 'getLocalRepo' )->willReturn( $mockLocalRepo );
+ $mockRepoGroup->expects( $this->never() )
+ ->method( $this->anythingBut( 'getLocalRepo', '__destruct' ) );
+
return new MovePage(
$old,
$new,
),
$mockLB,
$params['nsInfo'] ?? $this->getNoOpMock( NamespaceInfo::class ),
- $params['wiStore'] ?? $this->getNoOpMock( WatchedItemStore::class )
+ $params['wiStore'] ?? $this->getNoOpMock( WatchedItemStore::class ),
+ $params['permMgr'] ?? $this->getNoOpMock( PermissionManager::class ),
+ $params['repoGroup'] ?? $mockRepoGroup
);
}