From 8dac9d9daaa81e3ee2c94148cdbe68ec92db4673 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Tue, 2 Aug 2005 18:53:34 +0000 Subject: [PATCH] fixed not found page problem --- docs/changelog/6.x.x.txt | 2 ++ lib/WebGUI.pm | 30 +++++++++++++++++------------- lib/WebGUI/Asset.pm | 3 ++- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 9dc7d2d0d..0bdc7d486 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -1,4 +1,6 @@ 6.7.0 + - Fixed a potential problem where editing a page under rare very rare + conditions could destroy the not found page. - Added the ability to override the UI Level of any field in the edit form of any asset in the WebGUI config file. - Translation providers can now add languageAbbreviation and locale diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm index 9c7519714..8a3926c7a 100644 --- a/lib/WebGUI.pm +++ b/lib/WebGUI.pm @@ -89,20 +89,24 @@ sub page { my $output = _processOperations(); if ($output eq "") { my $asset = WebGUI::Asset->newByUrl($assetUrl); - $session{asset} = $asset; - my $method = "view"; - if (exists $session{form}{func}) { - $method = $session{form}{func}; - } - $method = "www_".$method; - $output = eval{$asset->$method()}; - if ($@) { - WebGUI::ErrorHandler::warn("Couldn't call method ".$method." on asset for ".$session{env}{PATH_INFO}." Root cause: ".$@); - $output = $asset->www_view; - } else { - if ($output eq "" && $method ne "view") { - $output = $asset->www_view; + if (defined $asset) { + $session{asset} = $asset; + my $method = "view"; + if (exists $session{form}{func}) { + $method = $session{form}{func}; } + $method = "www_".$method; + $output = eval{$asset->$method()}; + if ($@) { + WebGUI::ErrorHandler::warn("Couldn't call method ".$method." on asset for ".$session{env}{PATH_INFO}." Root cause: ".$@); + $output = $asset->www_view; + } else { + if ($output eq "" && $method ne "view") { + $output = $asset->www_view; + } + } + } else { + $output = WebGUI::Asset->getNotFound->www_view; } } WebGUI::Affiliate::grabReferral(); # process affilliate tracking request diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index af43b0841..3437bc54c 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -1056,7 +1056,8 @@ sub newByUrl { if ($id ne "" || $class ne "") { return WebGUI::Asset->new($id, $class, $version); } else { - return WebGUI::Asset->getNotFound; + WebGUI::ErrorHandler::warn("The URL $url was requested, but does not exist in your asset tree."); + return undef; } } return WebGUI::Asset->getDefault;