Reedy has uploaded a new change for review.
https://gerrit.wikimedia.org/r/51055
Change subject: Code cleanup, keeping back compat
......................................................................
Code cleanup, keeping back compat
Change-Id: I37f546892ea8ad5369af3e66c16062fab492dd56
---
M UserFunctions.php
M UserFunctions_body.php
2 files changed, 13 insertions(+), 37 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UserFunctions
refs/changes/55/51055/1
diff --git a/UserFunctions.php b/UserFunctions.php
index 6cd4535..4bfcdff 100644
--- a/UserFunctions.php
+++ b/UserFunctions.php
@@ -58,7 +58,6 @@
* @param $parser Parser
* @return bool
*/
-
function wfRegisterUserFunctions( $parser ) {
global $wgUFEnablePersonalDataFunctions, $wgUFAllowedNamespaces,
$wgUFEnableSpecialContexts;
@@ -66,52 +65,28 @@
$cur_ns = -1;
// Whether it's a Special Page or a Maintenance Script
- $special = false;
+ $special = true;
// Depending on MW version
if (class_exists("RequestContext")) {
- $pagetitle = RequestContext::getMain()->getTitle();
- if (method_exists($pagetitle, 'getNamespace' )) {
- $cur_ns = $pagetitle->getNamespace();
- if ($cur_ns == -1) {
- $special = true;
- }
- }
- else {
- $special = true;
- }
+ $pageTitle = RequestContext::getMain()->getTitle();
} else {
global $wgTitle;
- if (method_exists($wgTitle, 'getNamespace' )) {
- $cur_ns = $wgTitle->getNamespace();
- if ($cur_ns == -1) {
- $special = true;
- }
- }
- else {
- $special = true;
- }
+ $pageTitle = $wgTitle;
}
- $process = false;
-
- // As far it's not special case, check if current page NS is in the
allowed list
- if (!$special) {
- if (isset($wgUFAllowedNamespaces[$cur_ns])) {
- if ($wgUFAllowedNamespaces[$cur_ns]) {
- $process = true;
- }
- }
+ if (method_exists($pageTitle, 'getNamespace' )) {
+ $cur_ns = $pageTitle->getNamespace();
+ $special = ($cur_ns == NS_SPECIAL);
}
else {
- if ($wgUFEnableSpecialContexts) {
-
- if ($special) {
- $process = true;
- }
- }
+ $special = true;
}
+ // As far it's not special case, check if current page NS is in the
allowed list
+ $process = (!$special && isset($wgUFAllowedNamespaces[$cur_ns]) &&
$wgUFAllowedNamespaces[$cur_ns])
+ || ($wgUFEnableSpecialContexts && $special)) {
+
if ($process) {
// These functions accept DOM-style arguments
diff --git a/UserFunctions_body.php b/UserFunctions_body.php
index 6534734..8b485b6 100644
--- a/UserFunctions_body.php
+++ b/UserFunctions_body.php
@@ -101,8 +101,9 @@
# Considering multiple groups
$allgrp = explode(",", $grp);
+ $userGroups = $pUser->getEffectiveGroups();
foreach ( $allgrp as $elgrp ) {
- if ( in_array( trim( $elgrp ),
$pUser->getEffectiveGroups() ) ) {
+ if ( in_array( trim( $elgrp ), $userGroups ) ) {
return isset( $args[1] ) ? trim(
$frame->expand( $args[1] ) ) : '';
}
}
--
To view, visit https://gerrit.wikimedia.org/r/51055
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I37f546892ea8ad5369af3e66c16062fab492dd56
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UserFunctions
Gerrit-Branch: master
Gerrit-Owner: Reedy <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits