[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] Improve smarty error handling for missing tpls

"Jonny Bradley \(@jonnybradley\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6995d84f7bf42_3b186d84-3e4@gitlab-sidekiq-low-urgency-cpu-bound-v2-68c86796b8-z8pz9.mail>

Jonny Bradley pushed to branch 27.x at Tiki Wiki CMS Groupware / Tiki


Commits:
e1bc2db4 by Jonny Bradley at 2026-02-18T15:15:51+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]>

(cherry picked from commit 6232283ce87e3e5e9054b475e6dea4fd3f1afe0a)

Co-authored-by: Jonny Bradley <[email protected]>
- - - - -


1 changed file:

- lib/init/smarty.php


Changes:

=====================================
lib/init/smarty.php
=====================================
@@ -270,18 +270,23 @@ class Smarty_Tiki extends \Smarty\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);
@@ -297,10 +302,10 @@ class Smarty_Tiki extends \Smarty\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/e1bc2db4a6577dd5f55ab52ef918babddf2a99ea

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/e1bc2db4a6577dd5f55ab52ef918babddf2a99ea
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.