Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/258495

Change subject: Optimise order of permission checks
......................................................................

Optimise order of permission checks

First check whether the action is whitelisted, because that's a very
cheap check. User::getName() can easily be expensive, even triggering
autocreation in some cases.

Change-Id: I709d1153e1e1c787f732110db2e9c660ec5de38c
---
M includes/TorBlockHooks.php
1 file changed, 3 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TorBlock 
refs/changes/95/258495/1

diff --git a/includes/TorBlockHooks.php b/includes/TorBlockHooks.php
index 9ac7fe0..3b21d0d 100644
--- a/includes/TorBlockHooks.php
+++ b/includes/TorBlockHooks.php
@@ -37,12 +37,12 @@
        private static function checkUserCan( User $user, $action = null ) {
                global $wgTorAllowedActions, $wgRequest, $wgUser;
 
-               // Just in case we're checking another user
-               if ( $user->getName() !== $wgUser->getName() ) {
+               if ( $action !== null && in_array( $action, 
$wgTorAllowedActions ) ) {
                        return true;
                }
 
-               if ( $action !== null && in_array( $action, 
$wgTorAllowedActions ) ) {
+               // Just in case we're checking another user
+               if ( $user->getName() !== $wgUser->getName() ) {
                        return true;
                }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/258495
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I709d1153e1e1c787f732110db2e9c660ec5de38c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TorBlock
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to