From: Aaron Schulz Date: Thu, 10 Sep 2015 22:47:54 +0000 (-0700) Subject: Avoid master queries on image history view X-Git-Tag: 1.31.0-rc.0~9951^2 X-Git-Url: http://git.cyclocoop.org//%27http:/jquery.khurshid.com/ifixpng.php/%27?a=commitdiff_plain;h=592a6e7d2e4f750c79b278ec18a4af6d001ef122;p=lhc%2Fweb%2Fwiklou.git Avoid master queries on image history view * The path that needs READ_LATEST already calls load() as needed first Bug: T92357 Change-Id: Ia06bba6c2853823add2e527bb1b013b64d3f020a --- diff --git a/includes/page/ImagePage.php b/includes/page/ImagePage.php index 62dd1e32ae..d7bd568486 100644 --- a/includes/page/ImagePage.php +++ b/includes/page/ImagePage.php @@ -712,7 +712,7 @@ EOT $canUpload = $this->getTitle()->userCan( 'upload', $this->getContext()->getUser() ); if ( $canUpload && UploadBase::userCanReUpload( $this->getContext()->getUser(), - $this->mPage->getFile()->name ) + $this->mPage->getFile() ) ) { $ulink = Linker::makeExternalLink( $this->getUploadUrl(), diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index b06b91e4a7..30a85aec14 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -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' ); }