Merge "Move callers away from Title::GAID_FOR_UPDATE"
[lhc/web/wiklou.git] / includes / api / ApiImageRotate.php
index 7045138..1f8b012 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use MediaWiki\MediaWikiServices;
+
 /**
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -56,7 +59,9 @@ class ApiImageRotate extends ApiBase {
                                }
                        }
 
-                       $file = wfFindFile( $title, [ 'latest' => true ] );
+                       $file = MediaWikiServices::getInstance()->getRepoGroup()->findFile(
+                               $title, [ 'latest' => true ]
+                       );
                        if ( !$file ) {
                                $r['result'] = 'Failure';
                                $r['errors'] = $this->getErrorFormatter()->arrayFromStatus(
@@ -96,8 +101,10 @@ class ApiImageRotate extends ApiBase {
                                continue;
                        }
                        $ext = strtolower( pathinfo( "$srcPath", PATHINFO_EXTENSION ) );
-                       $tmpFile = TempFSFile::factory( 'rotate_', $ext, wfTempDir() );
+                       $tmpFile = MediaWikiServices::getInstance()->getTempFSFileFactory()
+                               ->newTempFSFile( 'rotate_', $ext );
                        $dstPath = $tmpFile->getPath();
+                       // @phan-suppress-next-line PhanUndeclaredMethod
                        $err = $handler->rotate( $file, [
                                'srcPath' => $srcPath,
                                'dstPath' => $dstPath,
@@ -107,6 +114,7 @@ class ApiImageRotate extends ApiBase {
                                $comment = wfMessage(
                                        'rotate-comment'
                                )->numParams( $rotation )->inContentLanguage()->text();
+                               // @phan-suppress-next-line PhanUndeclaredMethod
                                $status = $file->upload(
                                        $dstPath,
                                        $comment,