From be259d803ce99f8a4ef92961bfd3d83826722937 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sat, 5 Jun 2010 22:25:18 -0700 Subject: [PATCH 1/7] Fix problems with assetExportHtml. The method needs to be rethought, and make check that one exists before calling it via can/DOES. Fix a problem with duplicating the session, since duplicate is not a class method. --- lib/WebGUI/Asset/Wobject/StoryArchive.pm | 2 +- lib/WebGUI/Role/Asset/RssFeed.pm | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/WebGUI/Asset/Wobject/StoryArchive.pm b/lib/WebGUI/Asset/Wobject/StoryArchive.pm index c33fa526f..d11f62f88 100644 --- a/lib/WebGUI/Asset/Wobject/StoryArchive.pm +++ b/lib/WebGUI/Asset/Wobject/StoryArchive.pm @@ -196,7 +196,7 @@ sub exportAssetCollateral { } # open another session to handle printing... - my $printSession = WebGUI::Session->duplicate; + my $printSession = $self->session->duplicate; my $keywordObj = WebGUI::Keyword->new($printSession); my $keywords = $keywordObj->findKeywords({ diff --git a/lib/WebGUI/Role/Asset/RssFeed.pm b/lib/WebGUI/Role/Asset/RssFeed.pm index c3c6216b8..34b776524 100644 --- a/lib/WebGUI/Role/Asset/RssFeed.pm +++ b/lib/WebGUI/Role/Asset/RssFeed.pm @@ -165,9 +165,10 @@ The session doing the full export. Can be used to report status messages. =cut -sub exportAssetCollateral { +around exportAssetCollateral => sub { # Lots of copy/paste here from AssetExportHtml.pm, since none of the methods there were # directly useful without ginormous refactoring. + my $orig = shift; my $self = shift; my $basepath = shift; my $args = shift; @@ -209,7 +210,7 @@ sub exportAssetCollateral { $reportSession->output->print( '      ' . $message . '
'); } - my $exportSession = WebGUI::Session->duplicate; + my $exportSession = $self->session->duplicate; # open another session as the user doing the exporting... my $selfdupe = WebGUI::Asset->newById( $exportSession, $self->getId ); @@ -242,8 +243,8 @@ sub exportAssetCollateral { $reportSession->output->print($reporti18n->get('done')); } } - return $self->next::method($basepath, $args, $reportSession); -} + return $self->$orig(@_); +}; #------------------------------------------------------------------- From 963591d5e1ca501fffc5c1a21a4e80c11cdcb4fc Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 7 Jun 2010 15:49:07 -0700 Subject: [PATCH 2/7] Fix a bad around wrapper in the RssFeed assetExportHtml sub. --- lib/WebGUI/Role/Asset/RssFeed.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/WebGUI/Role/Asset/RssFeed.pm b/lib/WebGUI/Role/Asset/RssFeed.pm index 34b776524..d61d103fe 100644 --- a/lib/WebGUI/Role/Asset/RssFeed.pm +++ b/lib/WebGUI/Role/Asset/RssFeed.pm @@ -243,7 +243,7 @@ around exportAssetCollateral => sub { $reportSession->output->print($reporti18n->get('done')); } } - return $self->$orig(@_); + return $self->$orig($basepath, $args, $reportSession); }; #------------------------------------------------------------------- From 9c99fa2f92b9709eb809e654ccde380a7488305d Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Sat, 8 May 2010 16:35:54 -0500 Subject: [PATCH 3/7] clean up some parts of WebGUI::Test --- t/lib/WebGUI/Test.pm | 64 ++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/t/lib/WebGUI/Test.pm b/t/lib/WebGUI/Test.pm index ee21fb5bb..299ddc3c6 100644 --- a/t/lib/WebGUI/Test.pm +++ b/t/lib/WebGUI/Test.pm @@ -57,8 +57,6 @@ our @EXPORT_OK = qw(session config collateral); my $CLASS = __PACKAGE__; -my @guarded; - sub import { our $CONFIG_FILE = $ENV{ WEBGUI_CONFIG }; @@ -80,7 +78,7 @@ sub _initSession { my $session = our $SESSION = $CLASS->newSession(1); my $originalSetting = clone $session->setting->get; - push @guarded, Scope::Guard->new(sub { + $CLASS->addToCleanup(sub { while (my ($param, $value) = each %{ $originalSetting }) { $session->setting->set($param, $value); } @@ -110,7 +108,7 @@ sub _initSession { my ($label, $table) = @checkCount[$i, $i+1]; $initCounts{$table} = $session->db->quickScalar('SELECT COUNT(*) FROM ' . $table); } - push @guarded, Scope::Guard->new(sub { + $CLASS->addToCleanup(sub { for ( my $i = 0; $i < @checkCount; $i += 2) { my ($label, $table) = @checkCount[$i, $i+1]; my $quant = $session->db->quickScalar('SELECT COUNT(*) FROM ' . $table); @@ -127,19 +125,6 @@ END { $CLASS->cleanup; } -sub cleanup { - # remove guards in reverse order they were added, triggering all of the - # requested cleanup operations - pop @guarded - while @guarded; - - if ( our $SESSION ) { - $SESSION->var->end; - $SESSION->close; - undef $SESSION; - } -} - #---------------------------------------------------------------------------- =head2 newSession ( $noCleanup ) @@ -159,7 +144,7 @@ sub newSession { my $session = WebGUI::Session->open( $CLASS->config ); $session->{_request} = $pseudoRequest; if ( ! $noCleanup ) { - $CLASS->sessionsToDelete($session); + $CLASS->addToCleanup($session); } return $session; } @@ -570,7 +555,7 @@ sub prepareMailServer { # Let it start up yo sleep 2; - push @guarded, Scope::Guard->new(sub { + $CLASS->addToCleanup(sub { # Close SMTPD if ($smtpdPid) { kill INT => $smtpdPid; @@ -603,7 +588,7 @@ sub originalConfig { } # add cleanup handler if this is the first time we were run if (! keys %originalConfig) { - push @guarded, Scope::Guard->new(sub { + $class->addToCleanup(sub { while (my ($key, $value) = each %originalConfig) { if (defined $value) { $CLASS->session->config->set($key, $value); @@ -619,7 +604,7 @@ sub originalConfig { #---------------------------------------------------------------------------- -=head2 getMail ( ) +=head2 getMail ( ) Read a sent mail from the prepared mail server (L) @@ -627,7 +612,7 @@ Read a sent mail from the prepared mail server (L) sub getMail { my $json; - + if ( !$smtpdSelect ) { return from_json ' { "error": "mail server not prepared" }'; } @@ -638,11 +623,11 @@ sub getMail { else { $json = ' { "error": "mail not sent" } '; } - + if (!$json) { $json = ' { "error": "error in getting mail" } '; } - + return from_json( $json ); } @@ -662,7 +647,7 @@ sub getMailFromQueue { if ( !$smtpdSelect ) { $class->prepareMailServer; } - + my $messageId = $CLASS->session->db->quickScalar( "SELECT messageId FROM mailQueue" ); warn $messageId; return unless $messageId; @@ -673,6 +658,7 @@ sub getMailFromQueue { return $class->getMail; } + #---------------------------------------------------------------------------- =head2 sessionsToDelete ( $session, [$session, ...] ) @@ -687,7 +673,7 @@ This is a class method. sub sessionsToDelete { my $class = shift; - push @guarded, cleanupGuard(@_); + $class->addToCleanup(@_); } #---------------------------------------------------------------------------- @@ -704,7 +690,7 @@ This is a class method. sub assetsToPurge { my $class = shift; - push @guarded, cleanupGuard(@_); + $class->addToCleanup(@_); } #---------------------------------------------------------------------------- @@ -720,7 +706,7 @@ This is a class method. sub groupsToDelete { my $class = shift; - push @guarded, cleanupGuard(@_); + $class->addToCleanup(@_); } @@ -737,7 +723,7 @@ This is a class method. sub storagesToDelete { my $class = shift; - push @guarded, cleanupGuard(map { + $class->addToCleanup(map { ref $_ ? $_ : ('WebGUI::Storage' => $_) } @_); } @@ -754,7 +740,7 @@ This is a class method. sub tagsToRollback { my $class = shift; - push @guarded, cleanupGuard(@_); + $class->addToCleanup(@_); } #---------------------------------------------------------------------------- @@ -770,7 +756,7 @@ This is a class method. sub usersToDelete { my $class = shift; - push @guarded, cleanupGuard(@_); + $class->addToCleanup(@_); } #---------------------------------------------------------------------------- @@ -786,7 +772,7 @@ This is a class method. sub workflowsToDelete { my $class = shift; - push @guarded, cleanupGuard(@_); + $class->addToCleanup(@_); } @@ -1004,12 +990,26 @@ This is a class method. =cut +my @guarded; sub addToCleanup { shift if eval { $_[0]->isa($CLASS) }; push @guarded, cleanupGuard(@_); } +sub cleanup { + # remove guards in reverse order they were added, triggering all of the + # requested cleanup operations + pop @guarded + while @guarded; + + if ( our $SESSION ) { + $SESSION->var->end; + $SESSION->close; + undef $SESSION; + } +} + #---------------------------------------------------------------------------- =head1 BUGS From 033fc6c5d346eeb9d25368b7877a2957e372e24f Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Tue, 11 May 2010 20:01:16 -0500 Subject: [PATCH 4/7] allow skipping test cleanup --- t/lib/WebGUI/Test.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/t/lib/WebGUI/Test.pm b/t/lib/WebGUI/Test.pm index 299ddc3c6..3dccd24d4 100644 --- a/t/lib/WebGUI/Test.pm +++ b/t/lib/WebGUI/Test.pm @@ -998,6 +998,12 @@ sub addToCleanup { } sub cleanup { + if ($ENV{WEBGUI_TEST_NOCLEANUP}) { + (pop @guarded)->dismiss + while @guarded; + return; + } + # remove guards in reverse order they were added, triggering all of the # requested cleanup operations pop @guarded From 5cb384ec73554f80208f6e7ad5e28cc2b672ce92 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Sun, 16 May 2010 21:45:44 -0500 Subject: [PATCH 5/7] ensure JSON is loaded --- lib/WebGUI/Types.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/WebGUI/Types.pm b/lib/WebGUI/Types.pm index 9be43a946..0fed3d275 100644 --- a/lib/WebGUI/Types.pm +++ b/lib/WebGUI/Types.pm @@ -17,6 +17,7 @@ package WebGUI::Types; use Moose; use Moose::Util::TypeConstraints; +use JSON (); =head1 NAME From 1e2b6fd0c2bf0822cc4ead7108d3f8b8fcab86c3 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Mon, 10 May 2010 16:40:15 -0500 Subject: [PATCH 6/7] allow undefined template or snippet text --- lib/WebGUI/Asset/Snippet.pm | 5 ++++- lib/WebGUI/Asset/Template.pm | 12 +++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/WebGUI/Asset/Snippet.pm b/lib/WebGUI/Asset/Snippet.pm index e10c1c8e7..0285316ce 100644 --- a/lib/WebGUI/Asset/Snippet.pm +++ b/lib/WebGUI/Asset/Snippet.pm @@ -54,7 +54,10 @@ property snippetPacked => ( sub _build_snippetPacked { my $self = shift; my $snippet = $self->snippet; - if ( $self->mimeType eq "text/html" ) { + if ( !defined $snippet ) { + # do nothing + } + elsif ( $self->mimeType eq "text/html" ) { HTML::Packer::minify( \$snippet, { remove_comments => 1, do_javascript => "shrink", diff --git a/lib/WebGUI/Asset/Template.pm b/lib/WebGUI/Asset/Template.pm index e7a9f698c..c4c9a6aec 100644 --- a/lib/WebGUI/Asset/Template.pm +++ b/lib/WebGUI/Asset/Template.pm @@ -80,11 +80,13 @@ property templatePacked => ( sub _build_templatePacked { my $self = shift; my $template = $self->template; - HTML::Packer::minify( \$template, { - remove_comments => 1, - do_javascript => 'shrink', - do_stylesheet => 'minify', - } ); + if (defined $template) { + HTML::Packer::minify( \$template, { + remove_comments => 1, + do_javascript => 'shrink', + do_stylesheet => 'minify', + } ); + } $template; } From 950d7517d6ccf8873adc57d081696455371a5ef2 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Mon, 7 Jun 2010 19:00:41 -0500 Subject: [PATCH 7/7] add IO::Socket::SSL as prereq for LDAPS --- sbin/testEnvironment.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/sbin/testEnvironment.pl b/sbin/testEnvironment.pl index 5bf279540..ba0f56a6b 100755 --- a/sbin/testEnvironment.pl +++ b/sbin/testEnvironment.pl @@ -147,6 +147,7 @@ checkModule("Test::Harness", "3.17" ); checkModule("DateTime::Event::ICal", "0.10" ); checkModule( "CHI", ); checkModule( "Cache::FastMmap", ); +checkModule('IO::Socket::SSL', ); failAndExit("Required modules are missing, running no more checks.") if $missingModule;