From 6ac30bb2ea1ba745829e654666545284c60cadb2 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 2 Jun 2009 20:30:48 +0000 Subject: [PATCH] Add noFormPost to packed content in the asset tables to prevent them from overwriting the data that has been packed from the filter function. Rerun the upgrade script to repack all areas that use packing. --- docs/changelog/7.x.x.txt | 1 + docs/upgrades/upgrade_7.7.8-7.7.9.pl | 42 ++++++++++++++++++++++++++++ lib/WebGUI/Asset.pm | 5 ++++ lib/WebGUI/Asset/Snippet.pm | 1 + lib/WebGUI/Asset/Template.pm | 1 + 5 files changed, 50 insertions(+) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index e51b751c8..5067c8e1d 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -13,6 +13,7 @@ - fixed Two sets of delete buttons for photos in the Story. - fixed #9920: Survey: cannot add questions in IE - fixed #10449: Undefined template + - fixed #10365: Head tags do not work "Use Packed Head Tags". 7.7.8 - fixed: Basic Auth doesn't work if password contains colon (Arjan Widlak, diff --git a/docs/upgrades/upgrade_7.7.8-7.7.9.pl b/docs/upgrades/upgrade_7.7.8-7.7.9.pl index adc80eda0..8862f0298 100644 --- a/docs/upgrades/upgrade_7.7.8-7.7.9.pl +++ b/docs/upgrades/upgrade_7.7.8-7.7.9.pl @@ -31,6 +31,7 @@ my $quiet; # this line required my $session = start(); # this line required # upgrade functions go here +repackTemplates( $session ); finish($session); # this line required @@ -44,6 +45,47 @@ finish($session); # this line required # print "DONE!\n" unless $quiet; #} +#---------------------------------------------------------------------------- +# Repack all templates since the packed columns may have been wiped out due to the bug. +sub repackTemplates { + my $session = shift; + + print "\n\t\tRepacking all templates that use packing, this may take a while..." unless $quiet; + my $sth = $session->db->read( "SELECT DISTINCT(assetId) FROM template where usePacked=1" ); + while ( my ($assetId) = $sth->array ) { + my $asset = WebGUI::Asset::Template->new( $session, $assetId ); + next unless $asset; + $asset->update({ + template => $asset->get('template'), + usePacked => 0, + }); + } + + print "\n\t\tRepacking head tags in assets that use packing, this may take a while..." unless $quiet; + $sth = $session->db->read( "SELECT assetId FROM asset where usePackedHeadTags=1" ); + while ( my ($assetId) = $sth->array ) { + my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); + next unless $asset; + $asset->update({ + extraHeadTags => $asset->get('extraHeadTags'), + usePackedHeadTags => 0, + }); + } + + print "\n\t\tRepacking snippets that use packing, this may take a while..." unless $quiet; + $sth = $session->db->read( "SELECT DISTINCT(assetId) FROM snippet where usePacked=1" ); + while ( my ($assetId) = $sth->array ) { + my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); + next unless $asset; + $asset->update({ + snippet => $asset->get('snippet'), + usePacked => 0, + }); + } + + print "\n\t... DONE!\n" unless $quiet; +} + # -------------- DO NOT EDIT BELOW THIS LINE -------------------------------- diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 448ac1b94..30c0ad022 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -452,6 +452,7 @@ sub definition { extraHeadTagsPacked => { fieldType => 'hidden', defaultValue => undef, + noFormPost => 1, }, usePackedHeadTags => { tab => "meta", @@ -1101,6 +1102,7 @@ Returns the extraHeadTags stored in the asset. Called in $self->session->style- sub getExtraHeadTags { my $self = shift; + $self->session->log->warn("usePackedHeadTags: ". $self->get('usePackedHeadTags')); return $self->get('usePackedHeadTags') ? $self->get('extraHeadTagsPacked') : $self->get("extraHeadTags") @@ -2027,6 +2029,7 @@ filter guidelines). sub packExtraHeadTags { my ( $self, $unpacked ) = @_; + $self->session->log->warn('packExtraHeadTags called with '. $unpacked); return $unpacked if !$unpacked; my $packed = $unpacked; HTML::Packer::minify( \$packed, { @@ -2035,7 +2038,9 @@ sub packExtraHeadTags { do_javascript => "shrink", do_stylesheet => "minify", } ); + $self->session->log->warn('updated extraHeadTagsPacked to '. $packed); $self->update({ extraHeadTagsPacked => $packed }); + $self->session->log->warn('extraHeadTagsPacked is '. $self->get('extraHeadTagsPacked')); return $unpacked; } diff --git a/lib/WebGUI/Asset/Snippet.pm b/lib/WebGUI/Asset/Snippet.pm index 80bfa2267..283d52b8d 100644 --- a/lib/WebGUI/Asset/Snippet.pm +++ b/lib/WebGUI/Asset/Snippet.pm @@ -77,6 +77,7 @@ sub definition { snippetPacked => { fieldType => "hidden", defaultValue => undef, + noFormPost => 1, }, usePacked => { tab => 'properties', diff --git a/lib/WebGUI/Asset/Template.pm b/lib/WebGUI/Asset/Template.pm index 0afbf6a08..b75bdbad0 100644 --- a/lib/WebGUI/Asset/Template.pm +++ b/lib/WebGUI/Asset/Template.pm @@ -101,6 +101,7 @@ sub definition { templatePacked => { fieldType => 'hidden', defaultValue => undef, + noFormPost => 1, }, usePacked => { fieldType => 'yesNo',