From 05a8fa245e5348c71c66172f513621ccf8205a13 Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Sat, 1 Aug 2015 14:28:39 +0200 Subject: [PATCH] - improvement show resource type and start of template source instead of uid on eval: and string: resource (forum topic 25630) --- change_log.txt | 3 ++- libs/Smarty.class.php | 2 +- .../smarty_internal_templatecompilerbase.php | 10 +++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/change_log.txt b/change_log.txt index e1fb1f25..f033394c 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,7 +1,8 @@  ===== 3.1.28-dev===== (xx.xx.2015) 01.08.2015 - update DateTime object can be instance of DateTimeImmutable since PHP5.5 https://github.com/smarty-php/smarty/pull/75 - + - improvement show resource type and start of template source instead of uid on eval: and string: resource (forum topic 25630) + 31.07.2015 - optimize {foreach} and {section} compiler diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 925d6916..d0d2d17b 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.28-dev/35'; + const SMARTY_VERSION = '3.1.28-dev/36'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/libs/sysplugins/smarty_internal_templatecompilerbase.php index f1c7d74f..16f442ce 100644 --- a/libs/sysplugins/smarty_internal_templatecompilerbase.php +++ b/libs/sysplugins/smarty_internal_templatecompilerbase.php @@ -1079,10 +1079,18 @@ abstract class Smarty_Internal_TemplateCompilerBase if (!isset($line)) { $line = $this->lex->line; } + if (in_array($this->template->source->type, array('eval', 'string'))) { + $templateName = $this->template->source->type . ':' . + trim(preg_replace('![\t\r\n]+!', ' ', strlen($this->lex->data) > 40 ? substr($this->lex->data, 0, 40) . + '...' : $this->lex->data)); + } else { + $templateName = $this->template->source->type . ':' . $this->template->source->filepath; + } + // $line += $this->trace_line_offset; $match = preg_split("/\n/", $this->lex->data); $error_text = 'Syntax error in template "' . - (empty($this->trace_filepath) ? $this->template->source->filepath : $this->trace_filepath) . '" on line ' . + (empty($this->trace_filepath) ? $templateName : $this->trace_filepath) . '" on line ' . ($line + $this->trace_line_offset) . ' "' . trim(preg_replace('![\t\r\n]+!', ' ', $match[$line - 1])) . '" '; if (isset($args)) {