r54194 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r54193 | r54194 (on ViewVC) | r54195 >
Date:08:31, 2 August 2009
Author:shinjiman
Status:ok
Tags:
Comment:Added back 'editusercssjs' right for regression and backward compatibility, per Code Review on r54153.
Modified paths:

Test cases

ParserTests

558 succeeded tests.

Diff [purge]

Index: trunk/phase3/includes/Title.php
===================================================================
--- trunk/phase3/includes/Title.php	(revision 54193)
+++ trunk/phase3/includes/Title.php	(revision 54194)
@@ -1282,11 +1282,14 @@
 		# XXX: this might be better using restrictions
 		# XXX: Find a way to work around the php bug that prevents using $this->userCanEditCssSubpage() 
 		#      and $this->userCanEditJsSubpage() from working
-		if( $this->isCssSubpage() && !$user->isAllowed('editusercss' ) && $action != 'patrol'
+		# XXX: right 'editusercssjs' is deprecated, for backward compatibility only
+		if( $this->isCssSubpage() && ( !$user->isAllowed('editusercssjs') || !$user->isAllowed('editusercss') )
+			&& $action != 'patrol'
 			&& !preg_match('/^'.preg_quote($user->getName(), '/').'\//', $this->mTextform) )
 		{
 			$errors[] = array('customcssjsprotected');
-		} else if( $this->isJsSubpage() && !$user->isAllowed('edituserjs' ) && $action != 'patrol'
+		} else if( $this->isJsSubpage() && ( !$user->isAllowed('editusercssjs') || !$user->isAllowed('edituserjs') )
+			&& $action != 'patrol'
 			&& !preg_match('/^'.preg_quote($user->getName(), '/').'\//', $this->mTextform) )
 		{
 			$errors[] = array('customcssjsprotected');
@@ -1725,7 +1728,8 @@
 	 */
 	public function userCanEditCssSubpage() {
 		global $wgUser;
-		return ( $wgUser->isAllowed('editusercss') || preg_match('/^'.preg_quote($wgUser->getName(), '/').'\//', $this->mTextform) );
+		return ( ( $wgUser->isAllowed('editusercssjs') && $wgUser->isAllowed('editusercss') ) 
+			|| preg_match('/^'.preg_quote($wgUser->getName(), '/').'\//', $this->mTextform) );
 	}
 	/**
 	 * Protect js subpages of user pages: can $wgUser edit
@@ -1736,7 +1740,8 @@
 	 */
 	public function userCanEditJsSubpage() {
 		global $wgUser;
-		return ( $wgUser->isAllowed('edituserjs') || preg_match('/^'.preg_quote($wgUser->getName(), '/').'\//', $this->mTextform) );
+		return ( ( $wgUser->isAllowed('editusercssjs') && $wgUser->isAllowed('edituserjs') )
+		       	|| preg_match('/^'.preg_quote($wgUser->getName(), '/').'\//', $this->mTextform) );
 	}
 
 	/**

Follow-up revisions

RevisionCommit summaryAuthorDate
r54247Added back 'right-editusercssjs' message for backward compatibility, for r54194.shinjiman00:11, 3 August 2009

Status & tagging log

Views
Toolbox