From 21e2d71560cb87191dd80ae0750d0190b45063c1 Mon Sep 17 00:00:00 2001 From: Derick Alangi Date: Tue, 14 May 2019 18:00:34 +0100 Subject: Replace some uses of deprecated wfFindFile() and wfLocalFile() These global functions were deprecated in 1.34 and services made available to replace them. See services below; * wfFindFile() - MediaWikiServices::getInstance()->getRepoGroup()->findFile() * wfLocalFind() - MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()->newFile() NOTES: * wfFindFile() and wfLocalFind() usages in tests have been ignored in this change per @Timo's comments about state of objects. * includes/upload/UploadBase.php also maintained for now as it causes some failures I don't fully understand, will investigate and handle it in a follow up patch. * Also, includes/MovePage.php Change-Id: I9437494de003f40fbe591321da7b42d16bb732d6 --- includes/api/ApiImageRotate.php | 7 ++++++- includes/api/ApiMove.php | 4 +++- includes/api/ApiQueryImageInfo.php | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'includes/api') diff --git a/includes/api/ApiImageRotate.php b/includes/api/ApiImageRotate.php index 704513822f87..668bd0e4272e 100644 --- a/includes/api/ApiImageRotate.php +++ b/includes/api/ApiImageRotate.php @@ -1,4 +1,7 @@ true ] ); + $file = MediaWikiServices::getInstance()->getRepoGroup()->findFile( + $title, [ 'latest' => true ] + ); if ( !$file ) { $r['result'] = 'Failure'; $r['errors'] = $this->getErrorFormatter()->arrayFromStatus( diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php index 89ecc43bd946..540860b3a9d9 100644 --- a/includes/api/ApiMove.php +++ b/includes/api/ApiMove.php @@ -20,6 +20,8 @@ * @file */ +use MediaWiki\MediaWikiServices; + /** * API Module to move pages * @ingroup API @@ -59,7 +61,7 @@ class ApiMove extends ApiBase { if ( $toTitle->getNamespace() == NS_FILE && !RepoGroup::singleton()->getLocalRepo()->findFile( $toTitle ) - && wfFindFile( $toTitle ) + && MediaWikiServices::getInstance()->getRepoGroup()->findFile( $toTitle ) ) { if ( !$params['ignorewarnings'] && $user->isAllowed( 'reupload-shared' ) ) { $this->dieWithError( 'apierror-fileexists-sharedrepo-perm' ); diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 051e12796f08..e123a2ac468c 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -110,7 +110,8 @@ class ApiQueryImageInfo extends ApiQueryBase { if ( !isset( $images[$title] ) ) { if ( isset( $prop['uploadwarning'] ) || isset( $prop['badfile'] ) ) { // uploadwarning and badfile need info about non-existing files - $images[$title] = wfLocalFile( $title ); + $images[$title] = MediaWikiServices::getInstance()->getRepoGroup() + ->getLocalRepo()->newFile( $title ); // Doesn't exist, so set an empty image repository $info['imagerepository'] = ''; } else { -- cgit v1.2.3