jenkins-bot has submitted this change and it was merged.

Change subject: Recognize namespace constants named '*_NS_*' too. (v1.6.4)
......................................................................


Recognize namespace constants named '*_NS_*' too. (v1.6.4)

Some extensions name namespace constants *_NS_* instead of NS_*. Such
constants are now also made available to the PhpTags user.

Change-Id: I027714da47fd115e01ec08fc16cbabdd47adc1c8
---
M PhpTagsWiki.init.php
M PhpTagsWiki.php
2 files changed, 16 insertions(+), 7 deletions(-)

Approvals:
  Pastakhov: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/PhpTagsWiki.init.php b/PhpTagsWiki.init.php
index d07ae3f..04b6afa 100644
--- a/PhpTagsWiki.init.php
+++ b/PhpTagsWiki.init.php
@@ -12,12 +12,21 @@
        }
 
        public static function initializeConstants() {
-               // Add all defined namespace constants (that starts with 'NS_')
-               $phpConsts = get_defined_constants( true );
-               $ns_keys = array_filter( array_keys( $phpConsts['user'] ), 
function( $key ){ return substr( $key, 0, 3 ) === "NS_"; } );
-               $ns_consts = array_intersect_key( $phpConsts['user'], 
array_flip($ns_keys) );
-               array_walk( $ns_consts, function(&$value){ $value = 
(int)$value; } ); // save NS_SQL_PASSWORD or NS_MY_CREDIT_CARD :)
-               return $ns_consts;
+               // Add all defined namespace constants, which either
+               // start with 'NS_' or have '_NS_' in their names
+               $phpConstants = get_defined_constants( true );
+               $nsConstants = array();
+               foreach ( $phpConstants['user'] as $key => $value ) {
+                       if ( !is_int( $value ) ) {
+                               continue;
+                       }
+                       $pos = strpos( $key, 'NS_' );
+                       if ( $pos === false || ( $pos > 0 && $key[$pos - 1] !== 
'_' ) ) {
+                               continue;
+                       }
+                       $nsConstants[$key] = $value;
+               }
+               return $nsConstants;
        }
 
 }
diff --git a/PhpTagsWiki.php b/PhpTagsWiki.php
index 1b0f024..e22755b 100644
--- a/PhpTagsWiki.php
+++ b/PhpTagsWiki.php
@@ -15,7 +15,7 @@
        die( 'This file is an extension to MediaWiki and thus not a valid entry 
point.' );
 }
 
-const PHPTAGS_WIKI_VERSION = '1.6.3';
+const PHPTAGS_WIKI_VERSION = '1.6.4';
 
 // Register this extension on Special:Version
 $wgExtensionCredits['phptags'][] = array(

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I027714da47fd115e01ec08fc16cbabdd47adc1c8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PhpTagsWiki
Gerrit-Branch: master
Gerrit-Owner: JoelKP <joelkpetters...@gmail.com>
Gerrit-Reviewer: Pastakhov <pastak...@yandex.ru>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to