*
* RepoGroup::singleton()->getLocalRepo()->newFile( $title );
*
- * The convenience functions wfLocalFile() and wfFindFile() should be sufficient
- * in most cases.
+ * Consider the services container below;
+ *
+ * $services = MediaWikiServices::getInstance();
+ *
+ * The convenience services $services->getRepoGroup()->getLocalRepo()->newFile()
+ * and $services->getRepoGroup()->findFile() should be sufficient in most cases.
+ *
+ * @TODO: DI - Instead of using MediaWikiServices::getInstance(), a service should
+ * ideally accept a RepoGroup in its constructor and then, use $this->repoGroup->findFile()
+ * and $this->repoGroup->getLocalRepo()->newFile().
*
* @ingroup FileAbstraction
*/
* @param FileRepo $repo
* @param null $unused
*
- * @return self
+ * @return static
*/
static function newFromTitle( $title, $repo, $unused = null ) {
- return new self( $title, $repo );
+ return new static( $title, $repo );
}
/**
* @param stdClass $row
* @param FileRepo $repo
*
- * @return self
+ * @return static
*/
static function newFromRow( $row, $repo ) {
$title = Title::makeTitle( NS_FILE, $row->img_name );
- $file = new self( $title, $repo );
+ $file = new static( $title, $repo );
$file->loadFromRow( $row );
return $file;
$conds['img_timestamp'] = $dbr->timestamp( $timestamp );
}
- $fileQuery = self::getQueryInfo();
+ $fileQuery = static::getQueryInfo();
$row = $dbr->selectRow(
$fileQuery['tables'], $fileQuery['fields'], $conds, __METHOD__, [], $fileQuery['joins']
);
if ( $row ) {
- return self::newFromRow( $row, $repo );
+ return static::newFromRow( $row, $repo );
} else {
return false;
}
* @return Status
*/
function move( $target ) {
+ $localRepo = MediaWikiServices::getInstance()->getRepoGroup();
if ( $this->getRepo()->getReadOnlyReason() !== false ) {
return $this->readOnlyFatalStatus();
}
wfDebugLog( 'imagemove', "Finished moving {$this->name}" );
// Purge the source and target files...
- $oldTitleFile = wfLocalFile( $this->title );
- $newTitleFile = wfLocalFile( $target );
+ $oldTitleFile = $localRepo->findFile( $this->title );
+ $newTitleFile = $localRepo->findFile( $target );
// To avoid slow purges in the transaction, move them outside...
DeferredUpdates::addUpdate(
new AutoCommitUpdate(