Ejegg has submitted this change and it was merged.

Change subject: Allow overriding with dissimilar types
......................................................................


Allow overriding with dissimilar types

Sometimes inst-args[0] needs to be an array, even when the default
value is a string.

Change-Id: I27577bdfd72b1733e69b3787cfb7e40d3b56098f
---
M Core/Configuration.php
M Tests/ConfigurationTest.php
2 files changed, 4 insertions(+), 22 deletions(-)

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



diff --git a/Core/Configuration.php b/Core/Configuration.php
index cf99144..ae537fc 100644
--- a/Core/Configuration.php
+++ b/Core/Configuration.php
@@ -385,13 +385,10 @@
                                $baseNodeRef = &$base[$graftNodeName];
                                // Nodes that are present in the base and in 
the graft
 
-                               if (!self::isMergable($baseNodeRef, 
$graftNodeValue)) {
-                                       // Stop if types don't match.
-                                       throw new SmashPigException(
-                                               "Dissimilar types cannot be 
merged at configuration node {$node}." );
-                               }
-
-                               if ( is_array( $graftNodeValue ) ) {
+                               if (
+                                       is_array( $graftNodeValue ) &&
+                                       self::isMergable( $baseNodeRef, 
$graftNodeValue )
+                               ) {
                                        // Recursively merge arrays.
                                        static::treeMerge( $baseNodeRef, 
$graftNodeValue, $node );
                                } else {
diff --git a/Tests/ConfigurationTest.php b/Tests/ConfigurationTest.php
index d12732f..4cace76 100644
--- a/Tests/ConfigurationTest.php
+++ b/Tests/ConfigurationTest.php
@@ -5,21 +5,6 @@
  */
 class ConfigurationTest extends BaseSmashPigUnitTestCase {
 
-       /**
-        * Make sure we throw an exception when overriding a node with a 
different
-        * type.
-        *
-        * @expectedException \SmashPig\Core\SmashPigException
-        * @expectedExceptionMessage Dissimilar types cannot be merged at 
configuration node map_or_list.
-        *
-        * At integration level because the treeMerge function is currently
-        * protected.
-        */
-       public function testTreeMergeDissimilarTypes() {
-               $this->setConfig( 'aview', __DIR__ . '/data/dissimilar.yaml' );
-               // expectedException above
-       }
-
        public function testOverride() {
                $config = $this->setConfig();
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I27577bdfd72b1733e69b3787cfb7e40d3b56098f
Gerrit-PatchSet: 5
Gerrit-Project: wikimedia/fundraising/SmashPig
Gerrit-Branch: master
Gerrit-Owner: Ejegg <eeggles...@wikimedia.org>
Gerrit-Reviewer: Awight <awi...@wikimedia.org>
Gerrit-Reviewer: Cdentinger <cdentin...@wikimedia.org>
Gerrit-Reviewer: Ejegg <eeggles...@wikimedia.org>
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