From 5a346afd9e3f8a28de9981ea61afeb78f2518d16 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 26 Jan 2010 10:39:20 -0800 Subject: [PATCH] Fix FilePump parsing of lastModified times when fetching files via HTTP, using DateTime::Format::HTTP. Fixes bug #11373. --- docs/changelog/7.x.x.txt | 1 + docs/gotcha.txt | 4 ++++ lib/WebGUI/FilePump/Bundle.pm | 7 ++++++- sbin/testEnvironment.pl | 1 + t/FilePump/Bundle.t | 31 ++++++++++++++++++------------- 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index ec544545c..b4bd2ef82 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -3,6 +3,7 @@ - fixed #11364: Notify About Low Stock workflow activity email is not user friendly - fixed #11371: Spaces in the names of custom profile fields - fixed #11372: All Search Forms should use GET + - fixed #11373: Problem creating FilePump bundles 7.8.10 - fixed #11332: Pagination in webgui.org forum urls diff --git a/docs/gotcha.txt b/docs/gotcha.txt index 60a0ce1d9..bdfb6d447 100644 --- a/docs/gotcha.txt +++ b/docs/gotcha.txt @@ -7,6 +7,10 @@ upgrading from one version to the next, or even between multiple versions. Be sure to heed the warnings contained herein as they will save you many hours of grief. +7.8.11 +-------------------------------------------------------------------- + * WebGUI now requires DateTime::Format::HTTP, to handle parsing HTTP dates. + 7.8.6 -------------------------------------------------------------------- * WebGUI now requires LWP 5.833 or higher, to fix a bug in that module. diff --git a/lib/WebGUI/FilePump/Bundle.pm b/lib/WebGUI/FilePump/Bundle.pm index df89d94de..2f082e2b1 100644 --- a/lib/WebGUI/FilePump/Bundle.pm +++ b/lib/WebGUI/FilePump/Bundle.pm @@ -10,6 +10,7 @@ use File::Basename; use CSS::Minifier::XS; use JavaScript::Minifier::XS; use LWP; +use DateTime::Format::HTTP; use Data::Dumper; #------------------------------------------------------------------- @@ -105,6 +106,8 @@ sub build { } $concatenatedJS .= $results->{content}; $jsFile->{lastModified} = $results->{lastModified}; + $self->session->log->warn($jsFile->{uri}); + $self->session->log->warn($jsFile->{lastModified}); } return (0, $error) if ($error); @@ -161,6 +164,7 @@ sub build { ##Minimize files, and write them out. + $self->session->log->warn($concatenatedJS); my $minimizedJS = JavaScript::Minifier::XS::minify($concatenatedJS); undef $concatenatedJS; @@ -618,9 +622,10 @@ sub fetchHttp { if (! $response->is_success) { return {}; } + my $lastModified = my $guts = { content => $response->content, - lastModified => $response->header('last-modified'), + lastModified => DateTime::Format::HTTP->parse_datetime($response->header('last-modified'))->epoch, }; return $guts; } diff --git a/sbin/testEnvironment.pl b/sbin/testEnvironment.pl index 2854ebdb1..325d1a528 100755 --- a/sbin/testEnvironment.pl +++ b/sbin/testEnvironment.pl @@ -88,6 +88,7 @@ checkModule("DateTime", 0.4501 ); checkModule("Time::HiRes", 1.9719 ); checkModule("DateTime::Format::Strptime", 1.0800 ); checkModule("DateTime::Format::Mail", 0.3001 ); +checkModule("DateTime::Format::Http", 0.38 ); checkModule("Image::Magick", "6.0" ); checkModule("Log::Log4perl", 1.20 ); checkModule("Net::LDAP", 0.39 ); diff --git a/t/FilePump/Bundle.t b/t/FilePump/Bundle.t index da960732a..d0017c795 100644 --- a/t/FilePump/Bundle.t +++ b/t/FilePump/Bundle.t @@ -18,6 +18,7 @@ use strict; use lib "$FindBin::Bin/../lib"; use Test::More; use Test::Deep; +use Test::Exception; use Data::Dumper; use URI; use WebGUI::Test; # Must use this before any other WebGUI modules @@ -33,17 +34,12 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -my $tests = 62; # Increment this number for each test you create -plan tests => 1 + $tests; # 1 for the use_ok +plan tests => 64; #---------------------------------------------------------------------------- # put your tests here -my $loaded = use_ok('WebGUI::FilePump::Bundle'); - -SKIP: { - -skip 'Unable to load module WebGUI::FilePump::Bundle', $tests unless $loaded; +use WebGUI::FilePump::Bundle; my $bundle = WebGUI::FilePump::Bundle->create($session); isa_ok($bundle, 'WebGUI::FilePump::Bundle'); @@ -438,11 +434,20 @@ ok($bundle->get('otherFiles')->[1]->{lastModified}, '... updated OTHER directory $bundle->delete; ok(!-e $buildDir->stringify, 'delete deletes the current build directory'); -} +################################################################### +# +# File checks +# +################################################################### -#---------------------------------------------------------------------------- -# Cleanup -END { - $session->db->write('delete from filePumpBundle'); +##Test a number of files that live in WebGUI to make sure the minifiers do +##the right job. All paths are relative to the extras directory. + +my @jsFiles = qw/hoverhelp.js inputcheck.js/; + +foreach my $jsFile (@jsFiles) { + my $bundle = WebGUI::FilePump::Bundle->create($session); + $bundle->addFile('JS', 'file:extras/'.$jsFile); + lives_ok { $bundle->build } "built file $jsFile"; + $bundle->delete; } -#vim:ft=perl