Fix bad interaction between WebGUI::Asset->new() and caching mechanism.

This commit is contained in:
Drake 2006-09-26 04:08:16 +00:00
parent 1dd24dd6b7
commit 4f7a3bf490
2 changed files with 13 additions and 0 deletions

View file

@ -20,6 +20,7 @@
- fix: robots.txt returns wrong MIME type - fix: robots.txt returns wrong MIME type
- change: overlong alternate text for Weather Data icons shortened to basename - 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: multiple problems with static export, including wrong asset context and wrong status messages
- fix: WebGUI::Asset->new interacting badly with caching
7.0.7 7.0.7
- rfe: Image Management (funded by Formation Design Systems) - rfe: Image Management (funded by Formation Design Systems)

View file

@ -1388,10 +1388,12 @@ sub new {
my $session = shift; my $session = shift;
my $assetId = shift; my $assetId = shift;
my $className = shift; my $className = shift;
unless (defined $assetId) { unless (defined $assetId) {
$session->errorHandler->error("Asset constructor new() requires an assetId."); $session->errorHandler->error("Asset constructor new() requires an assetId.");
return undef; return undef;
} }
my $assetRevision = $session->stow->get("assetRevision"); my $assetRevision = $session->stow->get("assetRevision");
my $revisionDate = shift || $assetRevision->{$assetId}{$session->scratch->get("versionTag")||'_'}; my $revisionDate = shift || $assetRevision->{$assetId}{$session->scratch->get("versionTag")||'_'};
unless ($revisionDate) { unless ($revisionDate) {
@ -1402,6 +1404,15 @@ sub new {
$session->stow->set("assetRevision",$assetRevision); $session->stow->set("assetRevision",$assetRevision);
} }
return undef unless ($revisionDate); 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) { if ($className) {
my $cmd = "use ".$className; my $cmd = "use ".$className;
eval ($cmd); eval ($cmd);
@ -1411,6 +1422,7 @@ sub new {
} }
$class = $className; $class = $className;
} }
my $cache = WebGUI::Cache->new($session, ["asset",$assetId,$revisionDate]); my $cache = WebGUI::Cache->new($session, ["asset",$assetId,$revisionDate]);
my $properties = $cache->get; my $properties = $cache->get;
if (exists $properties->{assetId}) { if (exists $properties->{assetId}) {