[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] Improve reset_app_menu method to handle multi-line INSERT statements and clean up queries

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6914e5108e3c6_2ce2a0446997@gitlab-sidekiq-low-urgency-cpu-bound-v2-554bcf6b6c-tt2m5.mail>

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


Commits:
f13ac517 by UshindiG at 2025-11-12T19:42:06+00:00
[FIX] Improve reset_app_menu method to handle multi-line INSERT statements and clean up queries
---
* [FIX] Improve reset_app_menu method to handle multi-line INSERT statements and clean up queries

See merge request tikiwiki/tiki!8922

- - - - -


1 changed file:

- lib/menubuilder/menulib.php


Changes:

=====================================
lib/menubuilder/menulib.php
=====================================
@@ -91,14 +91,20 @@ class MenuLib extends TikiLib
     public function reset_app_menu()
     {
         $tiki_sql = file_get_contents('db/tiki.sql');
-        preg_match_all('/^(?:INSERT|UPDATE) (?:INTO )?`?tiki_menu_options`? .*$/mi', $tiki_sql, $matches);
+
+        //handle multi-line INSERT statements
+        preg_match_all('/(?:INSERT\s+INTO\s+`?tiki_menu_options`?.*?;|UPDATE\s+tiki_menu_options\s+SET.*?;)/ims', $tiki_sql, $matches);
 
         if ($matches && count($matches[0])) {
             $menuoptions = $this->table('tiki_menu_options');
             $menuoptions->deleteMultiple([ 'menuId' => 42 ]);
 
             foreach ($matches[0] as $query) {
-                $this->query($query);
+                // remove extra whitespace and newlines
+                $query = preg_replace('/\s+/', ' ', trim($query));
+                if (! empty($query)) {
+                    $this->query($query);
+                }
             }
             $this->empty_menu_cache(42);
         }



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

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