Ori.livneh has uploaded a new change for review.

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


Change subject: Strip descriptions from ResourceLoaderSchemaModule modules
......................................................................

Strip descriptions from ResourceLoaderSchemaModule modules

Immutability and consistency should not be compromised lightly, but no one ever
looks at the descriptions client-side, so the bandwidth is wasted in affirming
this abstract principle.

Change-Id: Ibe13fb16917a7aaaebf91217e70004e366baa454
---
M EventLogging.php
M includes/ResourceLoaderSchemaModule.php
2 files changed, 20 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/EventLogging 
refs/changes/11/108211/1

diff --git a/EventLogging.php b/EventLogging.php
index 81a85a4..e5e0f12 100644
--- a/EventLogging.php
+++ b/EventLogging.php
@@ -195,6 +195,23 @@
 }
 
 
+/**
+ * Recursively remove a key from an array and all its subarray members.
+ * Does not detect cycles.
+ *
+ * @param array &$array Array from which key should be stripped.
+ * @param string $key Key to remove.
+ */
+function efStripKeyRecursive( &$array, $key ) {
+       unset( $array[ $key ] );
+       foreach( $array as $k => &$v ) {
+               if ( is_array( $v ) ) {
+                       efStripKeyRecursive( $v, $key );
+               }
+       }
+}
+
+
 // Classes
 
 $wgAutoloadClasses += array(
diff --git a/includes/ResourceLoaderSchemaModule.php 
b/includes/ResourceLoaderSchemaModule.php
index b6498f8..b95f36f 100644
--- a/includes/ResourceLoaderSchemaModule.php
+++ b/includes/ResourceLoaderSchemaModule.php
@@ -83,7 +83,9 @@
         * @return string: JavaScript code.
         */
        function getScript( ResourceLoaderContext $context ) {
-               $params = array( $this->schema->title, 
$this->schema->jsonSerialize() );
+               $schema = $this->schema->jsonSerialize();
+               efStripKeyRecursive( $schema, 'description' );
+               $params = array( $this->schema->title, $schema );
                return Xml::encodeJsCall( 'mediaWiki.eventLog.declareSchema', 
$params );
        }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibe13fb16917a7aaaebf91217e70004e366baa454
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/EventLogging
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <o...@wikimedia.org>

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

Reply via email to