[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] Improve smarty error handling for missing tpls
"Jonny Bradley \(@jonnybradley\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6995d79e1cf8_3b186aa0271c6@gitlab-sidekiq-low-urgency-cpu-bound-v2-68c86796b8-8qm4g.mail> |
Jonny Bradley pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki Commits: 6232283c by Jonny Bradley at 2026-02-18T15:13:07+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 (cherry picked from commit 7d2674ed5a40f6176feec6e5ec34f34ceef38649) 5aaab52c [FIX] smarty: Store the template filename before `parent:fetch()` so we can... a7cf0db9 [TRA] Add translation fn (thanks @luciash) Co-authored-by: Jonny Bradley <[email protected]> - - - - - 1 changed file: - lib/core/Tiki/Smarty/SmartyTiki.php Changes: ===================================== lib/core/Tiki/Smarty/SmartyTiki.php ===================================== @@ -143,18 +143,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); @@ -170,10 +175,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/6232283ce87e3e5e9054b475e6dea4fd3f1afe0a -- View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/6232283ce87e3e5e9054b475e6dea4fd3f1afe0a 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