r32370 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32369‎ | r32370 | r32371 >
Date:13:40, 24 March 2008
Author:simetrical
Status:old
Tags:
Comment:
Moving some optimization code into User::isAllowed instead of higher up in Title.php. Also, adding a comment so that people maybe aren't going to randomly remove it without thinking what it does. ;)
Modified paths:
  • /trunk/phase3/includes/Namespace.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -1770,9 +1770,16 @@
17711771 * @return boolean True: action is allowed, False: action should not be allowed
17721772 */
17731773 function isAllowed($action='') {
1774 - if ( $action === '' )
 1774+ global $wgGroupPermissions;
 1775+ if( $action === '' ) {
17751776 // In the spirit of DWIM
17761777 return true;
 1778+ }
 1779+ if( !empty( $wgGroupPermissions['*'][$action] ) ) {
 1780+ # Permissions are additive, so there's no need to unstub the User
 1781+ # object in this case.
 1782+ return true;
 1783+ }
17771784
17781785 return in_array( $action, $this->getRights() );
17791786 }
Index: trunk/phase3/includes/Title.php
@@ -1387,7 +1387,7 @@
13881388 * @todo fold these checks into userCan()
13891389 */
13901390 public function userCanRead() {
1391 - global $wgUser, $wgGroupPermissions;
 1391+ global $wgUser;
13921392
13931393 $result = null;
13941394 wfRunHooks( 'userCan', array( &$this, &$wgUser, 'read', &$result ) );
@@ -1395,10 +1395,6 @@
13961396 return $result;
13971397 }
13981398
1399 - # Shortcut for public wikis, allows skipping quite a bit of code
1400 - if ($wgGroupPermissions['*']['read'])
1401 - return true;
1402 -
14031399 if( $wgUser->isAllowed( 'read' ) ) {
14041400 return true;
14051401 } else {
Index: trunk/phase3/includes/Namespace.php
@@ -165,4 +165,4 @@
166166 return $index >= NS_MAIN;
167167 }
168168
169 -}
\ No newline at end of file
 169+}

Follow-up revisions

RevisionCommit summaryAuthorDate
r32371Actually, revert r32370. It might be a good idea, but it breaks the UserGetR...simetrical13:47, 24 March 2008

Status & tagging log