change the name of UploadBase::verifyPermissions() to verifyTitlePermissions() for...
authorNeil Kandalgaonkar <neilk@users.mediawiki.org>
Fri, 25 Mar 2011 20:37:26 +0000 (20:37 +0000)
committerNeil Kandalgaonkar <neilk@users.mediawiki.org>
Fri, 25 Mar 2011 20:37:26 +0000 (20:37 +0000)
includes/api/ApiUpload.php
includes/specials/SpecialUpload.php
includes/upload/UploadBase.php
includes/upload/UploadFromUrl.php

index 3d29b70..7af6818 100644 (file)
@@ -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' ) );
index 9072e7a..b17615c 100644 (file)
@@ -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,
index 4be6cd4..0741326 100644 (file)
@@ -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.
index f696f18..ed5ad5e 100644 (file)
@@ -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 );
        }
 
        /**