From 270f52aaaa0c26dd0d9e9206fa03f9185c079ec1 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Tue, 16 Nov 2010 18:47:51 -0600 Subject: [PATCH] fix 11954 Can't clear packed head tags --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset.pm | 6 +++++- t/Asset/Asset.t | 26 +++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 689e801a9..05330dd94 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -7,6 +7,7 @@ - fixed #11956: ExtendCalenderRecurrence bug - fixed #11965: FriendManager pagination and getUsersNotIn - fixed #11964: files show in trash and in old revisions + - fixed #11954: Can't clear packed head tags 7.10.4 - Added WebGUI::Fork api diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index f5fe175f9..0865c74c7 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -2308,7 +2308,11 @@ filter guidelines). sub packExtraHeadTags { my ( $self, $unpacked ) = @_; - return $unpacked if !$unpacked; + # If no more unpacked tags, remove the packed tags + if ( !$unpacked ) { + $self->update({ extraHeadTagsPacked => $unpacked }); + return; + } my $packed = $unpacked; HTML::Packer::minify( \$packed, { remove_newlines => 1, diff --git a/t/Asset/Asset.t b/t/Asset/Asset.t index 4f3bf6e6f..62203e141 100644 --- a/t/Asset/Asset.t +++ b/t/Asset/Asset.t @@ -172,7 +172,7 @@ sub definition { package main; -plan tests => 132 +plan tests => 134 + scalar(@fixIdTests) + scalar(@fixTitleTests) + 2*scalar(@getTitleTests) #same tests used for getTitle and getMenuTitle @@ -1011,6 +1011,30 @@ $session->http->setRedirectLocation(''); is $clippedAsset->checkView(), 'chunked', 'checkView: returns "chunked" when admin is on for cut asset'; is $session->http->getRedirectLocation, $clippedAsset->getUrl('func=manageClipboard'), '... cut asset sets redirect to manageClipboard'; +#---------------------------------------------------------------------------- +# packed head tags +use HTML::Packer; +my $asset = WebGUI::Asset->getImportNode( $session )->addChild({ + className => 'WebGUI::Asset::Snippet', +}); +my $unpacked = qq{ + + +this is my title + +}; +my $packed = $unpacked; +HTML::Packer::minify( \$packed, { + remove_newlines => 1, + do_javascript => "shrink", + do_stylesheet => "minify", +} ); +$asset->update({ extraHeadTags => $unpacked }); +is $asset->get('extraHeadTagsPacked'), $packed, 'extraHeadTagsPacked'; +$asset->update({ extraHeadTags => '' }); +ok !$asset->get('extraHeadTagsPacked'), 'extraHeadTagsPacked cleared'; + + ##Return an array of hashrefs. Each hashref describes a test ##for the fixId method.