- improvement show resource type and start of template source instead of uid on eval: and string: resource (forum topic 25630)

This commit is contained in:
Uwe Tews
2015-08-01 14:28:39 +02:00
parent 3d2a15be3c
commit 05a8fa245e
3 changed files with 12 additions and 3 deletions

View File

@ -1,7 +1,8 @@
 ===== 3.1.28-dev===== (xx.xx.2015)  ===== 3.1.28-dev===== (xx.xx.2015)
01.08.2015 01.08.2015
- update DateTime object can be instance of DateTimeImmutable since PHP5.5 https://github.com/smarty-php/smarty/pull/75 - 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 31.07.2015
- optimize {foreach} and {section} compiler - optimize {foreach} and {section} compiler

View File

@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = '3.1.28-dev/35'; const SMARTY_VERSION = '3.1.28-dev/36';
/** /**
* define variable scopes * define variable scopes

View File

@ -1079,10 +1079,18 @@ abstract class Smarty_Internal_TemplateCompilerBase
if (!isset($line)) { if (!isset($line)) {
$line = $this->lex->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; // $line += $this->trace_line_offset;
$match = preg_split("/\n/", $this->lex->data); $match = preg_split("/\n/", $this->lex->data);
$error_text = 'Syntax error in template "' . $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])) . ($line + $this->trace_line_offset) . ' "' . trim(preg_replace('![\t\r\n]+!', ' ', $match[$line - 1])) .
'" '; '" ';
if (isset($args)) { if (isset($args)) {