diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 2724f9490..fbece7c37 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -20,6 +20,7 @@ - fix: robots.txt returns wrong MIME type - change: overlong alternate text for Weather Data icons shortened to basename - fix: multiple problems with static export, including wrong asset context and wrong status messages + - fix: WebGUI::Asset->new interacting badly with caching 7.0.7 - rfe: Image Management (funded by Formation Design Systems) diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index e1b814225..1278954f9 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -1388,10 +1388,12 @@ sub new { my $session = shift; my $assetId = shift; my $className = shift; + unless (defined $assetId) { $session->errorHandler->error("Asset constructor new() requires an assetId."); return undef; } + my $assetRevision = $session->stow->get("assetRevision"); my $revisionDate = shift || $assetRevision->{$assetId}{$session->scratch->get("versionTag")||'_'}; unless ($revisionDate) { @@ -1402,6 +1404,15 @@ sub new { $session->stow->set("assetRevision",$assetRevision); } return undef unless ($revisionDate); + + unless ($class ne 'WebGUI::Asset' or defined $className) { + ($className) = $session->db->quickArray("select className from asset where assetId=?", [$assetId]); + unless ($className) { + $session->errorHandler->error("Couldn't instantiate asset: ".$assetId. ": couldn't find class name"); + return undef; + } + } + if ($className) { my $cmd = "use ".$className; eval ($cmd); @@ -1411,6 +1422,7 @@ sub new { } $class = $className; } + my $cache = WebGUI::Cache->new($session, ["asset",$assetId,$revisionDate]); my $properties = $cache->get; if (exists $properties->{assetId}) {