[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] [BP][FIX] Tracker item history: pre-render field values before template to...

"Bruno Kambere \(@kambereBr\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69f9e312bfba9_3818ff2448091@gitlab-sidekiq-low-urgency-cpu-bound-v2-7db4c49975-ljw9d.mail>

Bruno Kambere pushed to branch 27.x at Tiki Wiki CMS Groupware / Tiki


Commits:
0234986e by Bruno Kambere at 2026-05-05T15:21:55+03:00
[BP][FIX] Tracker item history: pre-render field values before template to avoid "Too late to modify headers"
---
* [BP][FIX] Tracker item history: pre-render field values before template to avoid "Too late to modify headers"
---
* [BP][FIX] Tracker item history: pre-render field values before template to avoid "Too late to modify headers"
---
* [FIX] Tracker item history: pre-render field values before template to avoid "Too late to modify headers"
---
* [FIX] Tracker item history: pre-render field values before template to avoid "Too late to modify headers"

See merge request tikiwiki/tiki!10052

See merge request tikiwiki/tiki!10132

See merge request tikiwiki/tiki!10142

See merge request tikiwiki/tiki!10143

- - - - -


2 changed files:

- lib/core/Services/Tracker/Controller.php
- templates/tracker/item_history.tpl


Changes:

=====================================
lib/core/Services/Tracker/Controller.php
=====================================
@@ -2356,30 +2356,51 @@ class Services_Tracker_Controller
                             ];
                         }
                     }
-                    if (TIKI_API) {
-                        $field_value = $field_option[$hist['fieldId']];
+                    // Pre-render field values here in the controller, before Smarty starts rendering the template.
+                    $field_value = $field_option[$hist['fieldId']];
+                    if (! empty($field_value['fieldId']) && $field_value['fieldId'] > 0) {
+                        $emptyTemplate = TikiLib::lib('smarty')->getEmptyInternalTemplate();
                         if (empty($diff_style)) {
-                            if (! empty($field_value['fieldId'])) {
+                            $field_value['value'] = $hist['value'];
+                            $hist['rendered_value'] = smarty_function_trackeroutput([
+                                'field' => $field_value,
+                                'list_mode' => 'csv',
+                                'history' => 'y',
+                                'item' => $item_info,
+                                'process' => 'y',
+                            ], $emptyTemplate);
+                            $field_value['value'] = $hist['new'];
+                            $hist['rendered_new'] = smarty_function_trackeroutput([
+                                'field' => $field_value,
+                                'list_mode' => 'csv',
+                                'history' => 'y',
+                                'item' => $item_info,
+                                'process' => 'y',
+                            ], $emptyTemplate);
+
+                            if (TIKI_API) {
+                                $hist['value'] = $hist['rendered_value'];
+                                $hist['new'] = $hist['rendered_new'];
                                 $field_value['value'] = $hist['value'];
-                                $hist['value'] = smarty_function_trackeroutput([
+                                $hist['rendered_value'] = smarty_function_trackeroutput([
                                     'field' => $field_value,
-                                    'list_mode' => 'csv',
+                                    'list_mode' => 'y',
                                     'history' => 'y',
                                     'item' => $item_info,
                                     'process' => 'y',
-                                ], TikiLib::lib('smarty')->getEmptyInternalTemplate());
+                                ], $emptyTemplate);
                                 $field_value['value'] = $hist['new'];
-                                $hist['new'] = smarty_function_trackeroutput([
+                                $hist['rendered_new'] = smarty_function_trackeroutput([
                                     'field' => $field_value,
-                                    'list_mode' => 'csv',
+                                    'list_mode' => 'y',
                                     'history' => 'y',
                                     'item' => $item_info,
                                     'process' => 'y',
-                                ], TikiLib::lib('smarty')->getEmptyInternalTemplate());
+                                ], $emptyTemplate);
                             }
                         } else {
                             $field_value['value'] = $hist['new'];
-                            $hist['diff'] = smarty_function_trackeroutput([
+                            $hist['rendered_diff'] = smarty_function_trackeroutput([
                                 'field' => $field_value,
                                 'list_mode' => 'y',
                                 'history' => 'y',
@@ -2387,25 +2408,11 @@ class Services_Tracker_Controller
                                 'process' => 'y',
                                 'oldValue' => $hist['value'],
                                 'diff_style' => $diff_style,
-                            ], TikiLib::lib('smarty')->getEmptyInternalTemplate());
-                        }
-                        if (! empty($field_value['fieldId'])) {
-                            $field_value['value'] = $hist['value'];
-                            $hist['rendered_value'] = smarty_function_trackeroutput([
-                                'field' => $field_value,
-                                'list_mode' => 'y',
-                                'history' => 'y',
-                                'item' => $item_info,
-                                'process' => 'y',
-                            ], TikiLib::lib('smarty')->getEmptyInternalTemplate());
-                            $field_value['value'] = $hist['new'];
-                            $hist['rendered_new'] = smarty_function_trackeroutput([
-                                'field' => $field_value,
-                                'list_mode' => 'y',
-                                'history' => 'y',
-                                'item' => $item_info,
-                                'process' => 'y',
-                            ], TikiLib::lib('smarty')->getEmptyInternalTemplate());
+                            ], $emptyTemplate);
+
+                            if (TIKI_API) {
+                                $hist['diff'] = $hist['rendered_diff'];
+                            }
                         }
                     }
                 }


=====================================
templates/tracker/item_history.tpl
=====================================
@@ -90,8 +90,8 @@
                             </td>
                             {if empty($diff_style)}
                                 {if !empty($field_value.fieldId) && $field_value.fieldId > 0}
-                                    <td class="text">{$field_value.value=$hist.value}{trackeroutput field=$field_value list_mode=csv item=$item_info history=y process=y}</td>
-                                    <td class="text">{$field_value.value=$hist.new}{trackeroutput field=$field_value list_mode=csv item=$item_info history=y process=y}</td>
+                                    <td class="text">{$hist.rendered_value}</td>
+                                    <td class="text">{$hist.rendered_new}</td>
                                 {else}
                                     <td class="text">{$hist.value|escape}</td>
                                     <td class="text">{$hist.new|escape}</td>
@@ -99,8 +99,7 @@
                             {else}
                                 <td colspan="2" class="tracker-diff {$diff_style}">
                                     {if !empty($field_value.fieldId) && $field_value.fieldId > 0}
-                                        {$field_value.value=$hist.new}
-                                        {trackeroutput field=$field_value list_mode='y' history=y item=$item_info process=y oldValue=$hist.value diff_style=$diff_style}
+                                        {$hist.rendered_diff}
                                     {else}
                                         {wikidiff object_type=direct oldver=$hist.value newver=$hist.new diff_style=$diff_style}
                                     {/if}



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/0234986eaa0d6a18cd0d146330ccfc68a989d8ab

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/0234986eaa0d6a18cd0d146330ccfc68a989d8ab
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
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.