From 43cf8e6d6e648f262685ea910abce34430de6421 Mon Sep 17 00:00:00 2001 From: Neil Kandalgaonkar Date: Fri, 25 Mar 2011 20:37:26 +0000 Subject: [PATCH] change the name of UploadBase::verifyPermissions() to verifyTitlePermissions() for clarity. A wrapper function is left for extensions that rely on the old method --- includes/api/ApiUpload.php | 2 +- includes/specials/SpecialUpload.php | 2 +- includes/upload/UploadBase.php | 15 +++++++++++++-- includes/upload/UploadFromUrl.php | 4 ++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index 3d29b705db..7af6818057 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -83,7 +83,7 @@ class ApiUpload extends ApiBase { $this->verifyUpload(); // Check permission to upload this file - $permErrors = $this->mUpload->verifyPermissions( $wgUser ); + $permErrors = $this->mUpload->verifyTitlePermissions( $wgUser ); if ( $permErrors !== true ) { // TODO: stash the upload and allow choosing a new name $this->dieUsageMsg( array( 'badaccess-groups' ) ); diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index 9072e7a31f..b17615c3f2 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -452,7 +452,7 @@ class SpecialUpload extends SpecialPage { } // Verify permissions for this title - $permErrors = $this->mUpload->verifyPermissions( $wgUser ); + $permErrors = $this->mUpload->verifyTitlePermissions( $wgUser ); if( $permErrors !== true ) { $code = array_shift( $permErrors[0] ); $this->showRecoverableUploadError( wfMsgExt( $code, diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index 4be6cd4f09..0741326bb1 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -27,7 +27,7 @@ abstract class UploadBase { const EMPTY_FILE = 3; const MIN_LENGTH_PARTNAME = 4; const ILLEGAL_FILENAME = 5; - const OVERWRITE_EXISTING_FILE = 7; # Not used anymore; handled by verifyPermissions() + const OVERWRITE_EXISTING_FILE = 7; # Not used anymore; handled by verifyTitlePermissions() const FILETYPE_MISSING = 8; const FILETYPE_BADTYPE = 9; const VERIFICATION_ERROR = 10; @@ -438,6 +438,17 @@ abstract class UploadBase { } } + /** + * Alias for verifyTitlePermissions. The function was originally 'verifyPermissions' + * but that suggests it's checking the user, when it's really checking the title + user combination. + * @param $user User object to verify the permissions against + * @return mixed An array as returned by getUserPermissionsErrors or true + * in case the user has proper permissions. + */ + public function verifyPermissions( $user ) { + return $this->verifyTitlePermissions( $user ); + } + /** * Check whether the user can edit, upload and create the image. This * checks only against the current title; if it returns errors, it may @@ -449,7 +460,7 @@ abstract class UploadBase { * @return mixed An array as returned by getUserPermissionsErrors or true * in case the user has proper permissions. */ - public function verifyPermissions( $user ) { + public function verifyTitlePermissions( $user ) { /** * If the image is protected, non-sysop users won't be able * to modify it by uploading a new revision. diff --git a/includes/upload/UploadFromUrl.php b/includes/upload/UploadFromUrl.php index f696f1872f..ed5ad5ec96 100644 --- a/includes/upload/UploadFromUrl.php +++ b/includes/upload/UploadFromUrl.php @@ -171,11 +171,11 @@ class UploadFromUrl extends UploadBase { * Wrapper around the parent function in order to defer checking protection * until we are sure that the file can actually be uploaded */ - public function verifyPermissions( $user ) { + public function verifyTitlePermissions( $user ) { if ( $this->mAsync ) { return true; } - return parent::verifyPermissions( $user ); + return parent::verifyTitlePermissions( $user ); } /** -- 2.20.1