jenkins-bot has submitted this change and it was merged.
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(-)
Approvals:
Aaron Schulz: Looks good to me, approved
jenkins-bot: Verified
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: merged
Gerrit-Change-Id: I709d1153e1e1c787f732110db2e9c660ec5de38c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TorBlock
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits