diff --git a/change_log.txt b/change_log.txt index d7551bfa..39c94e0a 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@ ===== trunk ===== +17.09.2013 + - improvement added patch for additional SmartyCompilerException properties for better access to scource information (forum topic 24559) + 16.09.2013 - bugfix recompiled templates did not show on first request with zend opcache cache (forum topic 24320) diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 294e662c..897b385a 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -1528,7 +1528,26 @@ class SmartyCompilerException extends SmartyException { return ' --> Smarty Compiler: ' . $this->message . ' <-- '; } - + /** + * The line number of the template error + * @type int|null + */ + public $line = null; + /** + * The template source snippet relating to the error + * @type string|null + */ + public $source = null; + /** + * The raw text of the error message + * @type string|null + */ + public $desc = null; + /** + * The resource identifier or template name + * @type string|null + */ + public $template = null; } /** diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/libs/sysplugins/smarty_internal_templatecompilerbase.php index c7b242c8..d7268fbf 100644 --- a/libs/sysplugins/smarty_internal_templatecompilerbase.php +++ b/libs/sysplugins/smarty_internal_templatecompilerbase.php @@ -798,7 +798,12 @@ abstract class Smarty_Internal_TemplateCompilerBase $error_text .= ', expected one of: ' . implode(' , ', $expect); } } - throw new SmartyCompilerException($error_text); + $e = new SmartyCompilerException($error_text); + $e->line = $line; + $e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[$line - 1])); + $e->desc = $args; + $e->template = $this->template->source->filepath; + throw $e; } }