[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] Make modal.tpl header-safe to prevent premature output during AJAX error handling

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <694999778b711_2a17fcc8897bc@gitlab-sidekiq-low-urgency-cpu-bound-v2-6bc58ff7bb-5cj9l.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
fd98faaf by Yves Ngalamulume at 2025-12-22T19:10:00+00:00
[FIX] Make modal.tpl header-safe to prevent premature output during AJAX error handling
---
* Deleting unused rows

* Deleting unused rows

* [FIX] Remove obsolete else branch from modal.tpl

* Changing the else part

* Changing the else part

* Changing the else part

* [FIX] Remove blank line before class closing brace

* [FIX] Move headerlib calls out of modal.tpl and into Broker.php to avoid premature output

* [FIX] Make modal.tpl header-safe to prevent premature output during AJAX error handling

* [FIX] HeaderLib: replace exceptions with warnings for header and JS footer output issues

See merge request tikiwiki/tiki!8839

- - - - -


2 changed files:

- lib/core/Services/Broker.php
- templates/layouts/internal/modal.tpl


Changes:

=====================================
lib/core/Services/Broker.php
=====================================
@@ -54,6 +54,7 @@ class Services_Broker
                 // Special handling for modal dialog requests
                 // Do not send an error code as bootstrap will just blank out
                 // Render the error as a modal
+                $this->prepareModalHeaderLib();
                 $smarty = TikiLib::lib('smarty');
                 $smarty->assign('title', tr('Oops'));
                 $smarty->assign('detail', ['message' => $e->getMessage()]);
@@ -70,6 +71,7 @@ class Services_Broker
                 // Special handling for modal dialog requests
                 // Do not send an error code as bootstrap will just blank out
                 // Render the error as a modal
+                $this->prepareModalHeaderLib();
                 $smarty = TikiLib::lib('smarty');
                 $smarty->assign('title', tr('Oops'));
                 $smarty->assign('detail', ['message' => $e->getMessage()]);
@@ -204,4 +206,12 @@ class Services_Broker
             return $smarty->fetch($template);
         }
     }
+
+    private function prepareModalHeaderLib()
+    {
+        $headerlib = TikiLib::lib('header');
+        $headerlib->output_js_config();
+        $headerlib->output_js_files();
+        $headerlib->output_js();
+    }
 }


=====================================
templates/layouts/internal/modal.tpl
=====================================
@@ -1,23 +1,25 @@
 <!DOCTYPE html>
 <div class="modal-content-storage">
-    {if ! isset($noheader) || $noheader !== 'y'}
+    {if !isset($noheader) || $noheader !== 'y'}
         <div class="modal-header title">
-            <h4 class="modal-title" id="myModalLabel">{$title|escape}{block name=subtitle}{/block}</h4>
-            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-hidden="true" aria-label="{tr}Close{/tr}"></button>
+            <h4 class="modal-title" id="myModalLabel">
+                {$title|escape}
+                {block name=subtitle}{/block}
+            </h4>
+            <button type="button"
+                    class="btn-close"
+                    data-bs-dismiss="modal"
+                    aria-hidden="true"
+                    aria-label="{tr}Close{/tr}">
+            </button>
         </div>
     {/if}
+
     <div class="body modal-body">
         {block name=content}{/block}
-        {if $headerlib}
-            {$headerlib->output_js_config()}
-            {$headerlib->output_js_files()}
-            {$headerlib->output_js()}
-        {/if}
-        {if $prefs.feature_debug_console eq 'y' and not empty($smarty.request.show_smarty_debug)}
-            {debug}
-        {/if}
     </div>
 </div>
+
 <div class="modal-footer">
     {block name=buttons}
         <button type="button" class="btn btn-link" data-bs-dismiss="modal">{tr}Close{/tr}</button>



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

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/fd98faafaa8695605f27f8ac772346e2b9ec012b
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.