Merge "Avoid master queries on image history view"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 21 Sep 2015 09:40:39 +0000 (09:40 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 21 Sep 2015 09:40:39 +0000 (09:40 +0000)
includes/page/ImagePage.php
includes/upload/UploadBase.php

index 43b12b2..9b9e3cb 100644 (file)
@@ -712,7 +712,7 @@ EOT
                $canUpload = $this->getTitle()->quickUserCan( 'upload', $this->getContext()->getUser() );
                if ( $canUpload && UploadBase::userCanReUpload(
                                $this->getContext()->getUser(),
-                               $this->mPage->getFile()->name )
+                               $this->mPage->getFile() )
                ) {
                        $ulink = Linker::makeExternalLink(
                                $this->getUploadUrl(),
index b06b91e..30a85ae 100644 (file)
@@ -1706,24 +1706,21 @@ abstract class UploadBase {
         * Check if a user is the last uploader
         *
         * @param User $user
-        * @param string $img Image name
+        * @param File $img
         * @return bool
         */
-       public static function userCanReUpload( User $user, $img ) {
+       public static function userCanReUpload( User $user, File $img ) {
                if ( $user->isAllowed( 'reupload' ) ) {
                        return true; // non-conditional
-               }
-               if ( !$user->isAllowed( 'reupload-own' ) ) {
+               } elseif ( !$user->isAllowed( 'reupload-own' ) ) {
                        return false;
                }
-               if ( is_string( $img ) ) {
-                       $img = wfLocalFile( $img );
-               }
+
                if ( !( $img instanceof LocalFile ) ) {
                        return false;
                }
 
-               $img->load( File::READ_LATEST );
+               $img->load();
 
                return $user->getId() == $img->getUser( 'id' );
        }