[TikiWiki-commits] [Git][tikiwiki/tiki][master] Improve smarty error handling for missing tpls
"Jonny Bradley \(@jonnybradley\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <698cbeb9b732d_3b18c4ba480569@gitlab-sidekiq-low-urgency-cpu-bound-v2-68c7d7f89f-58827.mail> |
Jonny Bradley pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
7d2674ed by Jonny Bradley at 2026-02-11T17:30:58+00:00
Improve smarty error handling for missing tpls
---
* [TRA] Add translation fn (thanks @luciash)
* [FIX] smarty: Store the template filename before `parent:fetch()` so we can report useful errors when the tpl is missing, and catch exceptions as well as errors as smarty now requires.
Also improve function [DOC]
See merge request tikiwiki/tiki!9535
- - - - -
1 changed file:
- lib/core/Tiki/Smarty/SmartyTiki.php
Changes:
=====================================
lib/core/Tiki/Smarty/SmartyTiki.php
=====================================
@@ -144,18 +144,23 @@ class SmartyTiki extends Smarty
}
/**
- * Override fetch method to sanitize tpl path before processing
- * @param string $_smarty_tpl_file
- * @param null $_smarty_cache_id
- * @param null $_smarty_compile_id
- * @param null $parent
- * @param bool $_smarty_display
- * @param bool $merge_tpl_vars
- * @param bool $no_output_filter
- * @return string
- */
+ * Override fetch method to sanitize tpl path before processing
+ *
+ * @param string $_smarty_tpl_file
+ * @param mixed $_smarty_cache_id
+ * @param mixed $_smarty_compile_id
+ * @param string $parent
+ * @param bool $_smarty_display
+ * @param bool $merge_tpl_vars
+ * @param bool $no_output_filter
+ *
+ * @return string
+ */
+
public function fetch($_smarty_tpl_file = null, $_smarty_cache_id = null, $_smarty_compile_id = null, $parent = null, $_smarty_display = false, $merge_tpl_vars = true, $no_output_filter = false)
{
+ // save the template in case there's an error
+ $tplFile = $_smarty_tpl_file;
// Sanitize tpl path
$_smarty_tpl_file = $this->get_filename($_smarty_tpl_file);
@@ -171,10 +176,10 @@ class SmartyTiki extends Smarty
} else {
$html = parent::fetch($_smarty_tpl_file, $_smarty_cache_id, $_smarty_compile_id, $parent);
}
- } catch (Error $e) {
+ } catch (Exception | Error $e) {
TikiLib::lib('errortracking')->captureException($e);
- $html = '<div class="error">';
- $html .= "Fatal error rendering template file $_smarty_tpl_file\n<br/>";
+ $html = '<div class="error mb-2">';
+ $html .= tr('Fatal error rendering template file "%0"', $tplFile);
$html .= '</div><pre>';
$html .= $e;
$html .= '</pre>';
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/7d2674ed5a40f6176feec6e5ec34f34ceef38649
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/7d2674ed5a40f6176feec6e5ec34f34ceef38649
You're receiving this email because of your account on gitlab.com.
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs