Throw an exception if the template file does not exist.
authorRobert Sesek <rsesek@bluestatic.org>
Tue, 4 Jun 2013 05:11:25 +0000 (01:11 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Tue, 4 Jun 2013 05:18:28 +0000 (01:18 -0400)
views/template_loader.php

index efa776ab7d286cf0396ccb914dfe1a1050152d92..58138f54c1661aaeaea1487bb2934ce37178b523 100644 (file)
@@ -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;