From 974a0b5b017b30c2f6deaa8ff03d29a4049e749e Mon Sep 17 00:00:00 2001 From: Ilmari Karonen Date: Thu, 22 May 2008 01:29:33 +0000 Subject: [PATCH] Make Special:Upload display detailed permissions errors. Also avoid checking for 'create' permissions if the target title already exists. --- RELEASE-NOTES | 2 ++ includes/SpecialUpload.php | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index aa2310b107..5ca8f7b669 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -43,6 +43,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN be filtered to only those within the range of $wgRCMaxAge. * $wgRCLinkLimits and $wgRCLinkDays allow for customization of the list and limits displayed on the recent changes special pages. +* The "createpage" permission is no longer required when uploading if the target + image page already exists. === New features in 1.13 === diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index fa70f252d7..147db6cce4 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -307,7 +307,7 @@ class UploadForm { break; case self::PROTECTED_PAGE: - $this->uploadError( wfMsgWikiHtml( 'protectedpage' ) ); + $wgOut->showPermissionsErrorPage( $details['permissionserrors'] ); break; case self::OVERWRITE_EXISTING_FILE: @@ -436,9 +436,15 @@ class UploadForm { * If the image is protected, non-sysop users won't be able * to modify it by uploading a new revision. */ - if( !$nt->userCan( 'edit' ) || - !$nt->userCan( 'create' ) || - !$nt->userCan( 'upload' ) ){ + $permErrors = $nt->getUserPermissionsErrors( 'edit', $wgUser ); + $permErrorsUpload = $nt->getUserPermissionsErrors( 'upload', $wgUser ); + $permErrorsCreate = ( $nt->exists() ? array() : $nt->getUserPermissionsErrors( 'create', $wgUser ) ); + + if( $permErrors || $permErrorsUpload || $permErrorsCreate ) { + // merge all the problems into one list, avoiding duplicates + $permErrors = array_merge( $permErrors, wfArrayDiff2( $permErrorsUpload, $permErrors ) ); + $permErrors = array_merge( $permErrors, wfArrayDiff2( $permErrorsCreate, $permErrors ) ); + $resultDetails = array( 'permissionserrors' => $permErrors ); return self::PROTECTED_PAGE; } -- 2.20.1