From 9080908c63865329b391357f6602ee14bf676b25 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 4 Jun 2013 01:11:25 -0400 Subject: [PATCH] Throw an exception if the template file does not exist. --- views/template_loader.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/views/template_loader.php b/views/template_loader.php index efa776a..58138f5 100644 --- a/views/template_loader.php +++ b/views/template_loader.php @@ -84,12 +84,16 @@ class TemplateLoader if (Profiling::IsProfilingEnabled() && !isset($this->usage[$name])) $this->usage[$name] = 0; + $tpl_path = $this->_TemplatePath($name); + if (!file_exists($tpl_path)) + throw new TemplateException("Template $name does not exist at path $tpl_path"); + // First check the memory cache. if (isset($this->cache[$name])) return clone $this->cache[$name]; // Then check if the cache backend has it. - $template = $this->_QueryCache($name); + $template = $this->_QueryCache($name, $tpl_path); if ($template) { $this->cache[$name] = $template; return clone $template; @@ -120,15 +124,15 @@ class TemplateLoader Queries the optional CacheBackend for a template. @param string Template name + @param string Template path @return Template|NULL */ - protected function _QueryCache($name) + protected function _QueryCache($name, $tpl_path) { if (!$this->cache_backend) return NULL; - $tpl_path = $this->_TemplatePath($name); $data = $this->cache_backend->GetTemplateDataForName($name, filemtime($tpl_path)); if (!$data) return NULL; -- 2.22.5