From 741b523ad39960938abb83d2020d19d39bcde0c8 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 25 May 2006 04:56:12 +0000 Subject: [PATCH] - fix create.sql / style3 - fix Spectre memory consumption - fix password vidible in debug mode - fix No way to add an advertisment to an adspace. --- docs/changelog/6.x.x.txt | 4 ++++ lib/Spectre/Admin.pm | 3 ++- lib/Spectre/Cron.pm | 15 +++++++++---- lib/Spectre/Workflow.pm | 34 ++++++++++++++++++++---------- lib/WebGUI/Operation/AdSpace.pm | 2 +- lib/WebGUI/Session/ErrorHandler.pm | 8 ++++++- 6 files changed, 48 insertions(+), 18 deletions(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 74fcc6a5f..c3aa15aab 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -3,6 +3,10 @@ - Data Forms now send email as HTML. - The back to site link generated after a CS post now leads back to the thread if the new post is a reply to a thread as discussed in Community IRC. + - fix create.sql / style3 + - fix Spectre memory consumption + - fix password vidible in debug mode + - fix No way to add an advertisment to an adspace. - Added full drag bar to the top of each asset as discussed in Community IRC. - fixed a bug in the project management app that was causing a no privilege error when trying to display the view. - fixed various bugs in the project management app. diff --git a/lib/Spectre/Admin.pm b/lib/Spectre/Admin.pm index 2fb4f7500..a0fc48367 100644 --- a/lib/Spectre/Admin.pm +++ b/lib/Spectre/Admin.pm @@ -99,7 +99,7 @@ Prints out error information. sub error { my $self = shift; my $output = shift; - print "ADMIN: ".$output."\n"; + print "ADMIN: [Error] ".$output."\n"; $self->getLogger->error("ADMIN: ".$output); } @@ -183,6 +183,7 @@ sub runTests { $self->debug("Running connectivity tests."); my $configs = WebGUI::Config->readAllConfigs($self->config->getWebguiRoot); foreach my $config (keys %{$configs}) { + next if $config =~ m/^demo/; $self->debug("Testing $config"); my $userAgent = new LWP::UserAgent; $userAgent->agent("Spectre"); diff --git a/lib/Spectre/Cron.pm b/lib/Spectre/Cron.pm index 203cec37a..6995ca541 100644 --- a/lib/Spectre/Cron.pm +++ b/lib/Spectre/Cron.pm @@ -40,6 +40,7 @@ sub _start { $self->debug("Loading the schedules from all the sites."); my $configs = WebGUI::Config->readAllConfigs($self->config->getWebguiRoot); foreach my $config (keys %{$configs}) { + next if $config =~ m/^demo/; $kernel->yield("loadSchedule", $config); } $kernel->yield("checkSchedules"); @@ -273,7 +274,7 @@ sub error { my $self = shift; my $output = shift; if ($self->{_debug}) { - print "CRON: ".$output."\n"; + print "CRON: [Error] ".$output."\n"; } $self->getLogger->error("CRON: ".$output); } @@ -372,8 +373,11 @@ sub runJob { $self->debug("Preparing to run a scheduled job ".$job->{taskId}."."); POE::Component::Client::UserAgent->new; if ($job->{sitename} eq "" || $job->{config} eq "" || $job->{taskId} eq "") { - $self->error("Warning: A scheduled task has corrupt information and is not able to be run. Skipping execution."); + $self->error("A scheduled task has corrupt information and is not able to be run. Skipping execution."); $kernel->yield("deleteJob",{config=>$job->{config}, taskId=>$job->{taskId}}) if ($job->{config} ne "" && $job->{taskId} ne ""); + } elsif ($self->{_errorCount}{$job->{config}}{$job->{taskId}} >= 5) { + $self->error("Scheduled task ".$job->{config}." / ".$job->{taskId}." has failed ".$self->{_errorCount}{$job->{config}}{$job->{taskId}}." times in a row and will no longer attempt to execute."); + $kernel->yield("deleteJob",{config=>$job->{config}, taskId=>$job->{taskId}}); } else { my $url = "http://".$job->{sitename}.':'.$self->config->get("webguiPort").$job->{gateway}; my $request = POST $url, [op=>"runCronJob", taskId=>$job->{taskId}]; @@ -414,23 +418,26 @@ sub runJobResponse { } my $state = $response->content; if ($state eq "done") { + $self->{_errorCount}{$config}{$taskId} = 0; $self->debug("Scheduled task $config / $taskId is now complete."); if ($job->{runOnce}) { $kernel->yield("deleteJob",{config=>$job->{config}, taskId=>$job->{taskId}}); } } elsif ($state eq "error") { + $self->{_errorCount}{$config}{$taskId}++; $self->debug("Got an error response for scheduled task $config / $taskId, will try again in ".$self->config->get("suspensionDelay")." seconds."); $kernel->delay_set("runJob",$self->config->get("suspensionDelay"),$job); } else { + $self->{_errorCount}{$config}{$taskId}++; $self->error("Something bad happened on the return of scheduled task $config / $taskId, will try again in ".$self->config->get("suspensionDelay")." seconds. ".$response->error_as_HTML); $kernel->delay_set("runJob",$self->config->get("suspensionDelay"),$job); } } elsif ($response->is_redirect) { - $self->debug("Response for $config / $taskId was redirected."); + $self->error("Response for $config / $taskId was redirected. This should never happen if configured properly!!!"); } elsif ($response->is_error) { $self->error("Response for scheduled task $config / $taskId had a communications error. ".$response->error_as_HTML); + $self->{_errorCount}{$config}{$taskId}++; $kernel->delay_set("runJob",$self->config->get("suspensionDelay"),$job); - # we should probably log something } } diff --git a/lib/Spectre/Workflow.pm b/lib/Spectre/Workflow.pm index b6fd5d22f..38e27f22f 100644 --- a/lib/Spectre/Workflow.pm +++ b/lib/Spectre/Workflow.pm @@ -36,6 +36,7 @@ sub _start { $self->debug("Reading workflow configs."); my $configs = WebGUI::Config->readAllConfigs($self->config->getWebguiRoot); foreach my $config (keys %{$configs}) { + next if $config =~ m/^demo/; $kernel->yield("loadWorkflows", $configs->{$config}); } $kernel->yield("checkInstances"); @@ -211,7 +212,7 @@ sub error { my $self = shift; my $output = shift; if ($self->{_debug}) { - print "WORKFLOW: ".$output."\n"; + print "WORKFLOW: [Error] ".$output."\n"; } $self->getLogger->error("WORKFLOW: ".$output); } @@ -355,17 +356,22 @@ Suspends a workflow instance for a number of seconds defined in the config file, sub suspendInstance { my ($self, $instanceId, $kernel) = @_[OBJECT, ARG0, KERNEL]; - $self->debug("Suspending workflow instance ".$instanceId." for ".$self->config->get("suspensionDelay")." seconds."); - # normally this is taken care of by the returnInstanceToQueue method, but we want to free up the running count - # so that other things can be run while this thing is suspended - if ($self->{_instances}{$instanceId}) { - for (my $i=0; $i < scalar(@{$self->{_runningInstances}}); $i++) { - if ($self->{_runningInstances}[$i] eq $instanceId) { - splice(@{$self->{_runningInstances}}, $i, 1); + if ($self->{_errorCount}{$instanceId} >= 5) { + $self->error("Workflow instance $instanceId has failed to execute ".$self->{_errorCount}{$instanceId}." times in a row and will no longer attempt to execute."); + $kernel->yield("deleteInstance",$instanceId); + } else { + $self->debug("Suspending workflow instance ".$instanceId." for ".$self->config->get("suspensionDelay")." seconds."); + # normally this is taken care of by the returnInstanceToQueue method, but we want to free up the running count + # so that other things can be run while this thing is suspended + if ($self->{_instances}{$instanceId}) { + for (my $i=0; $i < scalar(@{$self->{_runningInstances}}); $i++) { + if ($self->{_runningInstances}[$i] eq $instanceId) { + splice(@{$self->{_runningInstances}}, $i, 1); + } } } + $kernel->delay_set("returnInstanceToQueue",$self->config->get("suspensionDelay"), $instanceId); } - $kernel->delay_set("returnInstanceToQueue",$self->config->get("suspensionDelay"), $instanceId); } #------------------------------------------------------------------- @@ -392,30 +398,36 @@ sub workerResponse { } my $state = $response->content; if ($state eq "waiting") { + $self->{_errorCount}{$instanceId}=0; $self->debug("Was told to wait on $instanceId because we're still waiting on some external event."); $kernel->yield("suspendInstance",$instanceId); } elsif ($state eq "complete") { + $self->{_errorCount}{$instanceId}=0; $self->debug("Workflow instance $instanceId ran one of it's activities successfully."); $kernel->yield("returnInstanceToQueue",$instanceId); } elsif ($state eq "disabled") { + $self->{_errorCount}{$instanceId}=0; $self->debug("Workflow instance $instanceId is disabled."); $kernel->yield("suspendInstance",$instanceId); } elsif ($state eq "done") { + $self->{_errorCount}{$instanceId}=0; $self->debug("Workflow instance $instanceId is now complete."); $kernel->yield("deleteInstance",$instanceId); } elsif ($state eq "error") { + $self->{_errorCount}{$instanceId}++; $self->debug("Got an error response for $instanceId."); $kernel->yield("suspendInstance",$instanceId); } else { + $self->{_errorCount}{$instanceId}++; $self->error("Something bad happened on the return of $instanceId. ".$response->error_as_HTML); $kernel->yield("suspendInstance",$instanceId); } } elsif ($response->is_redirect) { - $self->debug("Response for $instanceId was redirected."); + $self->error("Response for $instanceId was redirected. This should never happen if configured properly!!!"); } elsif ($response->is_error) { + $self->{_errorCount}{$instanceId}++; $self->error("Response for $instanceId had a communications error. ".$response->error_as_HTML); $kernel->yield("suspendInstance",$instanceId) - # we should probably log something } } diff --git a/lib/WebGUI/Operation/AdSpace.pm b/lib/WebGUI/Operation/AdSpace.pm index 0efd51113..9b463920d 100644 --- a/lib/WebGUI/Operation/AdSpace.pm +++ b/lib/WebGUI/Operation/AdSpace.pm @@ -272,11 +272,11 @@ sub www_editAdSpace { my $ac = WebGUI::AdminConsole->new($session,"adSpace"); if (defined $adSpace) { $id = $adSpace->getId; - $ac->addSubmenuItem($session->url->page("op=editAd;adSpaceId=".$id), $i18n->get("add an ad")) if defined $adSpace; } else { $id = $session->form->param("adSpaceId") || "new"; $adSpace = WebGUI::AdSpace->new($session, $id); } + $ac->addSubmenuItem($session->url->page("op=editAd;adSpaceId=".$id), $i18n->get("add an ad")) if defined $adSpace; $ac->addSubmenuItem($session->url->page("op=manageAdSpaces"), $i18n->get("manage ad spaces")); my $f = WebGUI::HTMLForm->new($session); $f->submit; diff --git a/lib/WebGUI/Session/ErrorHandler.pm b/lib/WebGUI/Session/ErrorHandler.pm index c9b5ebc62..18455df8a 100644 --- a/lib/WebGUI/Session/ErrorHandler.pm +++ b/lib/WebGUI/Session/ErrorHandler.pm @@ -403,7 +403,13 @@ sub showDebug { $text = $self->session->stow->get('debug_info'); $text =~ s/\n/\
\n/g; $output .= '
'.$text."
\n"; - $text = JSON::objToJson($self->session->form->paramsHashRef(), {pretty => 1, indent => 4, autoconv=>0, skipinvalid=>1}); + my $form = $self->session->form->paramsHashRef(); + foreach my $key (keys %{$form}) { + if ($key eq "password" || $key eq "identifier") { + $form->{$key} = "********"; + } + } + $text = JSON::objToJson($form, {pretty => 1, indent => 4, autoconv=>0, skipinvalid=>1}); $text =~ s/&/&/xsg; $text =~ s/>/>/xsg; $text =~ s/