summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-04-15 16:30:32 -0700
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commitcd06b877cd97edb26551d9c30c399d666603e586 (patch)
tree6476caed75f4e00d8a699727f006408ddf47b8b3 /lib/puppet/parser
parent2de7da4fe3ad4a3821608141605829036ac5f1f8 (diff)
downloadpuppet-cd06b877cd97edb26551d9c30c399d666603e586.tar.gz
puppet-cd06b877cd97edb26551d9c30c399d666603e586.tar.xz
puppet-cd06b877cd97edb26551d9c30c399d666603e586.zip
Fix for #3556 Plussignment value melding
The plussignment operator was constructing the new parameter value by modifying the param object's value in place (so as to preserve the file and line information for debugging). However, when multiple resources are overridden by the same plussignment this would result in all of the resources sharing the same value (the union of all the prior values and the new value), which is wrong. Instead, we need to give each resource its own copy of the value (e.g., a copy of the param object), which this patch implements. Signed-off-by: Markus Roberts <Markus@reality.com>
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/resource.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index 7fcb7c1fc..1ae065f3c 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -324,10 +324,16 @@ class Puppet::Parser::Resource < Puppet::Resource
# If we've gotten this far, we're allowed to override.
- # Merge with previous value, if the parameter was generated with the +> syntax.
- # It's important that we use the new param instance here, not the old one,
- # so that the source is registered correctly for later overrides.
- param.value = [current.value, param.value].flatten if param.add
+ # Merge with previous value, if the parameter was generated with the +>
+ # syntax. It's important that we use a copy of the new param instance
+ # here, not the old one, and not the original new one, so that the source
+ # is registered correctly for later overrides but the values aren't
+ # implcitly shared when multiple resources are overrriden at once (see
+ # ticket #3556).
+ if param.add
+ param = param.dup
+ param.value = [current.value, param.value].flatten
+ end
set_parameter(param)
end