X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22brouteur%22%2C%28%24id_rubrique%20?a=blobdiff_plain;f=includes%2Ffilerepo%2Ffile%2FLocalFile.php;h=1e1bde38bebbe9cc2d59ca3c0710d43ec87017d8;hb=7bfec54fa5b74f93699509c1f1663806c3dac497;hp=2359fd6705e867c3ce1af35a375589cbc0acd9cf;hpb=94d8579d2c03b579ae83d8503d38aa593c566feb;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 2359fd6705..1e1bde38be 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 */ @@ -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 = []; @@ -1494,7 +1503,7 @@ class LocalFile extends File { 'img_sha1' => $this->sha1 ] + $commentFields + $actorFields, __METHOD__, - 'IGNORE' + [ 'IGNORE' ] ); $reupload = ( $dbw->affectedRows() == 0 ); @@ -1897,6 +1906,7 @@ class LocalFile extends File { * @return Status */ function move( $target ) { + $localRepo = MediaWikiServices::getInstance()->getRepoGroup(); 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->findFile( $this->title ); + $newTitleFile = $localRepo->findFile( $target ); // To avoid slow purges in the transaction, move them outside... DeferredUpdates::addUpdate( new AutoCommitUpdate(