Compare commits

...

2 Commits

Author SHA1 Message Date
Simon Wisselink 936b47d3d9 add note to 'other changes' in upgrade instructions 2024-02-24 22:50:39 +01:00
Simon Wisselink cc6812d6e0 Add template path to CompilerException to enable rich debug features
Fixes #935
2024-02-24 22:31:40 +01:00
5 changed files with 6 additions and 4 deletions
+1
View File
@@ -0,0 +1 @@
- Add template path to CompilerException to enable rich debug features [#935](https://github.com/smarty-php/smarty/issues/935)
+1
View File
@@ -117,6 +117,7 @@ The following constants have been removed to prevent global side effects.
- Smarty now always runs in multibyte mode. Make sure you use the [PHP multibyte extension](https://www.php.net/manual/en/book.mbstring.php) in production for optimal performance.
- Generated `<script>` tags lo longer have deprecated `type="text/javascript"` or `language="Javascript"` attributes
- Smarty will throw a compiler exception instead of silently ignoring a modifier on a function call, like this: `{include|dot:"x-template-id" file="included.dot.tpl"}`
- The ::getFile() method of a CompilerException will now return the full path of the template being compiled, if possible. This used to be 'file:relative_dir/filename.tpl'.
## Upgrading from v3 to v4
+1 -1
View File
@@ -121,6 +121,6 @@ class CodeFrame
* @return string
*/
public function insertLocalVariables(): string {
return '$_smarty_current_dir = ' . var_export(dirname($this->_template->getSource()->getFilepath()), true) . ";\n";
return '$_smarty_current_dir = ' . var_export(dirname($this->_template->getSource()->getFilepath() ?? '.'), true) . ";\n";
}
}
+1 -1
View File
@@ -848,7 +848,7 @@ class Template extends BaseCompiler {
$e = new CompilerException(
$error_text,
0,
$this->template->getSource()->getFullResourceName(),
$this->template->getSource()->getFilepath() ?? $this->template->getSource()->getFullResourceName(),
$line
);
$e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[$line - 1]));
+2 -2
View File
@@ -271,11 +271,11 @@ class Source {
return $this->type . ':' . $this->name;
}
public function getFilepath(): string {
public function getFilepath(): ?string {
if ($this->handler instanceof FilePlugin) {
return $this->handler->getFilePath($this->name, $this->smarty, $this->isConfig);
}
return '.';
return null;
}
public function isConfig(): bool {