X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=blobdiff_plain;f=includes%2Ffilerepo%2Ffile%2FLocalFile.php;h=d7d6bf78d8f29838f8a7c0e1840041dad92f0f0e;hb=b71610c069c69b2a991cb43b059642aca1882f4a;hp=99fd36d4fcc0d8860f69cb55e1ddbb3d880ede3c;hpb=c643f4a8ff48071afc13d22d12237a69122d3cde;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 99fd36d4fc..d7d6bf78d8 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -21,6 +21,7 @@ * @ingroup FileAbstraction */ +use Wikimedia\AtEase\AtEase; use MediaWiki\Logger\LoggerFactory; use Wikimedia\Rdbms\Database; use Wikimedia\Rdbms\IDatabase; @@ -38,8 +39,16 @@ use MediaWiki\MediaWikiServices; * * 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 */ @@ -141,10 +150,10 @@ class LocalFile extends File { * @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 ); } /** @@ -154,11 +163,11 @@ class LocalFile extends File { * @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; @@ -181,12 +190,12 @@ class LocalFile extends 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; } @@ -1337,7 +1346,7 @@ class LocalFile extends File { $options = []; $handler = MediaHandler::getHandler( $props['mime'] ); if ( $handler ) { - $metadata = Wikimedia\quietCall( 'unserialize', $props['metadata'] ); + $metadata = AtEase::quietCall( 'unserialize', $props['metadata'] ); if ( !is_array( $metadata ) ) { $metadata = []; @@ -1897,6 +1906,7 @@ class LocalFile extends File { * @return Status */ function move( $target ) { + $localRepo = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo(); if ( $this->getRepo()->getReadOnlyReason() !== false ) { return $this->readOnlyFatalStatus(); } @@ -1913,8 +1923,8 @@ class LocalFile extends File { wfDebugLog( 'imagemove', "Finished moving {$this->name}" ); // Purge the source and target files... - $oldTitleFile = wfLocalFile( $this->title ); - $newTitleFile = wfLocalFile( $target ); + $oldTitleFile = $localRepo->newFile( $this->title ); + $newTitleFile = $localRepo->newFile( $target ); // To avoid slow purges in the transaction, move them outside... DeferredUpdates::addUpdate( new AutoCommitUpdate(