Merge "Fixed fatal when using fake load balancers."
[lhc/web/wiklou.git] / includes / api / ApiImageRotate.php
index b2d7582..db82805 100644 (file)
@@ -22,7 +22,6 @@
  */
 
 class ApiImageRotate extends ApiBase {
-
        private $mPageSet = null;
 
        public function __construct( $main, $action ) {
@@ -53,16 +52,13 @@ class ApiImageRotate extends ApiBase {
                }
        }
 
-
        public function execute() {
                $params = $this->extractRequestParams();
-               $rotation = $params[ 'rotation' ];
-               $user = $this->getUser();
+               $rotation = $params['rotation'];
 
                $pageSet = $this->getPageSet();
                $pageSet->execute();
 
-               $result = array();
                $result = array();
 
                self::addValues( $result, $pageSet->getInvalidTitles(), 'invalid', 'title' );
@@ -111,15 +107,17 @@ class ApiImageRotate extends ApiBase {
                                continue;
                        }
                        $ext = strtolower( pathinfo( "$srcPath", PATHINFO_EXTENSION ) );
-                       $tmpFile = TempFSFile::factory( 'rotate_', $ext);
+                       $tmpFile = TempFSFile::factory( 'rotate_', $ext );
                        $dstPath = $tmpFile->getPath();
                        $err = $handler->rotate( $file, array(
                                "srcPath" => $srcPath,
                                "dstPath" => $dstPath,
-                               "rotation"=> $rotation
+                               "rotation" => $rotation
                        ) );
                        if ( !$err ) {
-                               $comment = wfMessage( 'rotate-comment' )->numParams( $rotation )->text();
+                               $comment = wfMessage(
+                                       'rotate-comment'
+                               )->numParams( $rotation )->inContentLanguage()->text();
                                $status = $file->upload( $dstPath,
                                        $comment, $comment, 0, false, false, $this->getUser() );
                                if ( $status->isGood() ) {
@@ -152,13 +150,14 @@ class ApiImageRotate extends ApiBase {
 
        /**
         * Checks that the user has permissions to perform rotations.
-        * @param $user User The user to check.
+        * @param User $user The user to check
+        * @param Title $title
         * @return string|null Permission error message, or null if there is no error
         */
        protected function checkPermissions( $user, $title ) {
                $permissionErrors = array_merge(
-                       $title->getUserPermissionsErrors( 'edit' , $user ),
-                       $title->getUserPermissionsErrors( 'upload' , $user )
+                       $title->getUserPermissionsErrors( 'edit', $user ),
+                       $title->getUserPermissionsErrors( 'upload', $user )
                );
 
                if ( $permissionErrors ) {
@@ -179,7 +178,6 @@ class ApiImageRotate extends ApiBase {
        }
 
        public function getAllowedParams( $flags = 0 ) {
-               $pageSet = $this->getPageSet();
                $result = array(
                        'rotation' => array(
                                ApiBase::PARAM_TYPE => array( '90', '180', '270' ),