newByLineage should log its own error. Fixes bug #11192

This commit is contained in:
Colin Kuskie 2009-11-02 18:29:46 -08:00
parent 3950611b47
commit 1eeb76e96f
3 changed files with 13 additions and 4 deletions

View file

@ -36,6 +36,7 @@
- fixed #11189: Controls variable missing in image asset in AssetProxy
- fixed #11190: event tmpl_var in help but not available
- fixed #11194: Event Asset Recurrence form is not i18n'ed
- fixed #11192: newByLineage tries to instantiate asset even if no assetId found
7.8.2
- Added scheduled vendor payout workflow activity. (Special thanks to Martin @ Oqapi)

View file

@ -821,6 +821,11 @@ sub newByLineage {
$class = $assetLineage->{$lineage}{class};
unless ($id && $class) {
($id,$class) = $session->db->quickArray("select assetId, className from asset where lineage=?",[$lineage]);
if (!$id || !$class) {
$session->errorHandler->error("Couldn't instantiate asset from lineage: ".$lineage. ": class name or assetId missing");
return undef;
}
return undef if !$id || !$class;
$assetLineage->{$lineage}{id} = $id;
$assetLineage->{$lineage}{class} = $class;
$session->stow->set("assetLineage",$assetLineage);

View file

@ -17,7 +17,7 @@ use WebGUI::Session;
use WebGUI::User;
use WebGUI::Asset;
use Test::More tests => 90; # increment this value for each test you create
use Test::More tests => 92; # increment this value for each test you create
use Test::Deep;
# Test the methods in WebGUI::AssetLineage
@ -388,16 +388,19 @@ my $snippet4 = WebGUI::Asset->newByLineage($session, $snippets[4]->get('lineage'
is ($snippet4->getId, $snippets[4]->getId, 'newByLineage returns correct Asset');
$snippet4 = WebGUI::Asset->newByLineage($session, $snippets[4]->get('lineage'));
is ($snippet4->getId, $snippets[4]->getId, 'newByLineage: cached lookup');
is ($snippet4->getId, $snippets[4]->getId, '... cached lookup');
my $cachedLineage = $session->stow->get('assetLineage');
delete $cachedLineage->{$snippet4->get('lineage')}->{id};
my $snippet4 = WebGUI::Asset->newByLineage($session, $snippets[4]->get('lineage'));
is ($snippet4->getId, $snippets[4]->getId, 'newByLineage: failing id cache forces lookup');
is ($snippet4->getId, $snippets[4]->getId, '... failing id cache forces lookup');
delete $cachedLineage->{$snippet4->get('lineage')}->{class};
my $snippet4 = WebGUI::Asset->newByLineage($session, $snippets[4]->get('lineage'));
is ($snippet4->getId, $snippets[4]->getId, 'newByLineage: failing class cache forces lookup');
is ($snippet4->getId, $snippets[4]->getId, '... failing class cache forces lookup');
is(WebGUI::Asset->newByLineage($session, 'notALineage'), undef, '... returns undef');
ok(!exists $session->stow->get('assetLineage')->{assetLineage}, '... no entry for the bad lineage in stow');
####################################################
#