From 86ecb101984bc55e49e215ae9944556b473606c2 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 20 Sep 2010 13:37:12 -0700 Subject: [PATCH] Keep comments when packing asset content, since it will also remove conditional comments for IE. Fixes bug #11876 --- docs/changelog/7.x.x.txt | 1 + docs/upgrades/upgrade_7.10.0-7.10.1.pl | 40 ++++++++++++++++++++++++++ lib/WebGUI/Asset.pm | 1 - lib/WebGUI/Asset/Snippet.pm | 1 - lib/WebGUI/Asset/Template.pm | 1 - 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index f4da992be..abab56630 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -13,6 +13,7 @@ - added findBrokenAssets.pl shows the classname of broken assets (William McKee, Knowmad Technologies) - fixed #11866: Default ordering for Zip files is wrong - fixed: typo in the Gallery Add Archive default templateId. + - fixed #11876: packing templates, snippets, headtags removes conditional CSS comments 7.10.0 - fixed #11812: Checking www_ajaxSave's response in the cart js, urlencoding post parameters diff --git a/docs/upgrades/upgrade_7.10.0-7.10.1.pl b/docs/upgrades/upgrade_7.10.0-7.10.1.pl index c43549801..0878e6bd1 100644 --- a/docs/upgrades/upgrade_7.10.0-7.10.1.pl +++ b/docs/upgrades/upgrade_7.10.0-7.10.1.pl @@ -33,6 +33,7 @@ my $session = start(); # this line required # upgrade functions go here uniqueProductLocations($session); removeBadSpanishFile($session); +repackTemplates( $session ); finish($session); # this line required @@ -76,6 +77,45 @@ sub removeBadSpanishFile { 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, this may take a while..." unless $quiet; + my $sth = $session->db->read( "SELECT assetId, revisionDate FROM template" ); + while ( my ($assetId, $revisionDate) = $sth->array ) { + my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId, $revisionDate ); + next unless $asset; + $asset->update({ + template => $asset->get('template'), + }); + } + + print "\n\t\tRepacking head tags in all assets, this may take a while..." unless $quiet; + $sth = $session->db->read( "SELECT assetId, revisionDate FROM assetData where usePackedHeadTags=1" ); + while ( my ($assetId, $revisionDate) = $sth->array ) { + my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId, $revisionDate ); + next unless $asset; + $asset->update({ + extraHeadTags => $asset->get('extraHeadTags'), + }); + } + + print "\n\t\tRepacking all snippets, this may take a while..." unless $quiet; + $sth = $session->db->read( "SELECT assetId, revisionDate FROM snippet" ); + while ( my ($assetId, $revisionDate) = $sth->array ) { + my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId, $revisionDate ); + next unless $asset; + $asset->update({ + snippet => $asset->get('snippet'), + }); + } + + print "\n\t... DONE!\n" unless $quiet; +} + + #---------------------------------------------------------------------------- # Describe what our function does #sub exampleFunction { diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 0634cce4b..f111c8450 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -2256,7 +2256,6 @@ sub packExtraHeadTags { return $unpacked if !$unpacked; my $packed = $unpacked; HTML::Packer::minify( \$packed, { - remove_comments => 1, remove_newlines => 1, do_javascript => "shrink", do_stylesheet => "minify", diff --git a/lib/WebGUI/Asset/Snippet.pm b/lib/WebGUI/Asset/Snippet.pm index fc8bf3213..63f12e710 100644 --- a/lib/WebGUI/Asset/Snippet.pm +++ b/lib/WebGUI/Asset/Snippet.pm @@ -242,7 +242,6 @@ sub packSnippet { if ( $self->get('mimeType') eq "text/html" ) { HTML::Packer::minify( \$packed, { - remove_comments => 1, do_javascript => "shrink", do_stylesheet => "minify", } ); diff --git a/lib/WebGUI/Asset/Template.pm b/lib/WebGUI/Asset/Template.pm index bdd0d2a65..265d8a278 100644 --- a/lib/WebGUI/Asset/Template.pm +++ b/lib/WebGUI/Asset/Template.pm @@ -525,7 +525,6 @@ sub packTemplate { my ( $self, $template ) = @_; my $packed = $template; HTML::Packer::minify( \$packed, { - remove_comments => 1, do_javascript => "shrink", do_stylesheet => "minify", } );