From 7bb998c6eea3ea995cc9418b9a55bde620b854de Mon Sep 17 00:00:00 2001 From: JT Smith Date: Wed, 24 Jan 2007 20:10:58 +0000 Subject: [PATCH] - Fixed a template variable rewriting problem with Template Toolkit. --- docs/changelog/7.x.x.txt | 5 +++- lib/WebGUI/Asset/Template/TemplateToolkit.pm | 29 ++++++++++---------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 352a5343b..689e02470 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,4 +1,5 @@ 7.3.7 + - Fixed a template variable rewriting problem with Template Toolkit. 7.3.6 - fix: Checkbox is no longer available when creating custom profile fields @@ -6,7 +7,9 @@ - fix: CS email message shows up as an attachment - fix: Calendar: start/end date time off in edit interface (perlDreamer Consulting, LLC) - Added a database optimization that will improve asset lookup performance by - as much as 600% on some sites. + as much as 600% on some sites and another small one that will improve a different + kind of lookup by more than 10%. + - fix: Extra cruft in the Zip Archive template. - fix: fixed corner case in WebGUI::Operation::Workflow.pm which could cause the edit page to not load and display an error if an activity is undefined or cannot be defined. - fix: testEnvironment.pl do not tests all modules (perlDreamer Consulting, LLC) diff --git a/lib/WebGUI/Asset/Template/TemplateToolkit.pm b/lib/WebGUI/Asset/Template/TemplateToolkit.pm index f523e4206..f17e43ed6 100755 --- a/lib/WebGUI/Asset/Template/TemplateToolkit.pm +++ b/lib/WebGUI/Asset/Template/TemplateToolkit.pm @@ -20,21 +20,22 @@ use Template; #------------------------------------------------------------------- sub _rewriteVars { # replace dots with underscrores in keys (except in keys that aren't usable as variables (URLs etc.)) - my $vars = shift; - foreach my $key (keys %$vars){ - my $newKey = $key; - $newKey =~ s/\./_/g if $newKey !~ /\//; - if(ref $vars->{$key} eq 'HASH'){ - $vars->{$newKey} = _rewriteVars($vars->{$key}); - delete $vars->{$key} if($key ne $newKey); - }else{ - if($key ne $newKey){ - $vars->{$newKey} = $vars->{$key}; - delete $vars->{$key}; + my $vars = shift; + my $newVars = {}; + foreach my $key (keys %$vars){ + my $newKey = $key; + $newKey =~ s/\./_/g if $newKey !~ /\//; + if ( ref $vars->{$key} eq 'ARRAY') { + foreach my $entry (@{$vars->{$key}}) { + push(@{$newVars->{$newKey}}, _rewriteVars($entry)); } - } - } - return $vars; + } elsif(ref $vars->{$key} eq 'HASH') { + $newVars->{$newKey} = _rewriteVars($vars->{$key}); + } else { + $newVars->{$newKey} = $vars->{$key}; + } + } + return $newVars; } #-------------------------------------------------------------------