From 9a45ff4b9119d376342c61e8fbfe1d94d3ff7c34 Mon Sep 17 00:00:00 2001 From: Scott Walters Date: Sat, 27 Oct 2012 01:59:18 -0400 Subject: [PATCH] on invalid proceed method in call to editSave, warn and recover rather than run time error --- docs/changelog/7.x.x.txt | 2 ++ lib/WebGUI/Asset.pm | 9 +++++++-- t/Asset/Asset.t | 29 ++++++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index cac10d1d6..d0e9cdce7 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -13,6 +13,8 @@ - fixed #12386: Story Manager - Carousel rendering broken in Story - fixed #12386: Story Manager - Carousel rendering broken in Story - fixed #12384: Click and drag reordering does not work in IE9 + - fixed: MessageBoard tolerates Collaboration children not yet having a value for lastPostId + - on invalid proceed method in call to editSave, warn and recover rather than run time error 7.10.26 - fixed: Template diagnostics when called without a session asset. diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index e9c862957..18add461e 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -3162,9 +3162,14 @@ sub www_editSave { elsif ($proceed ne "") { my $method = "www_".$session->form->process("proceed"); $session->asset($object); - return $session->asset->$method(); + if( $session->asset->can($method) ) { + return $session->asset->$method(); + } + else { + $session->log->warn("proceed method of $method specified but that method doesn't exist in " . ref($session->asset)); + # else fall through to the default handling below + } } - $session->asset($object->getContainer); return $session->asset->www_view; } diff --git a/t/Asset/Asset.t b/t/Asset/Asset.t index 9907d545f..04ff8bff6 100644 --- a/t/Asset/Asset.t +++ b/t/Asset/Asset.t @@ -1,4 +1,5 @@ #------------------------------------------------------------------- +warn "warning = $warning"; # WebGUI is Copyright 2001-2009 Plain Black Corporation. #------------------------------------------------------------------- # Please read the legal notices (docs/legal.txt) and the license @@ -172,7 +173,7 @@ sub definition { package main; -plan tests => 138 +plan tests => 140 + scalar(@fixIdTests) + scalar(@fixTitleTests) + 2*scalar(@getTitleTests) #same tests used for getTitle and getMenuTitle @@ -309,6 +310,23 @@ cmp_deeply( [ "two", "three" ], "serialized property returns deserialized ref", ); + +do { + sleep 2; # so that we don't collide revisionDates + my $fatal_error; + my $warning; + local *WebGUI::Session::ErrorHandler::fatal = sub { my $self = shift; $fatal_error = shift; }; + local *WebGUI::Session::ErrorHandler::warn = sub { my $self = shift; $warning = shift; }; + local *WebGUI::Session::Form::validToken = sub { 1 }; + my $html = WebGUI::Test->getPage($ta, "www_editSave", { + userId => 3, + formParams => { synopsis => '[ "two", "three" ]', proceed => 'asfd' }, + }); + ok ! $fatal_error, "no fatal error on invalid &proceed argument to www_editSave"; + like $warning, qr/proceed method of www_asfd specified/, "warning about invalid proceed method generated"; +}; + + $ta->purge; ################################################################ @@ -1235,3 +1253,12 @@ subtest 'canAdd tolerates being called as an object method', sub { ok !$class->canAdd($session), 'Cannot add when called as a class method'; ok !$snip->canAdd($session), '...or an object method'; }; + +################################################################ +# +# www_editSave proceed parameter +# +################################################################ +{ +} +