[TikiWiki-commits] [Git][tikiwiki/tiki][tiki-fix-tracker-edit-jquery] 2 commits: Revert "[FIX] js buildParams avoid object object query serialization"

"Merci Jacob \(@mercihabam\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6997143a63e07_3b186bf411281@gitlab-sidekiq-low-urgency-cpu-bound-v2-68dc4b78c5-prtwc.mail>

Merci Jacob pushed to branch tiki-fix-tracker-edit-jquery at Tiki Wiki CMS Groupware / Tiki


Commits:
b5e03c49 by Merci Jacob at 2026-02-19T15:41:04+02:00
Revert "[FIX] js buildParams avoid object object query serialization"

This reverts commit 7f17bf8664c83b78dd3fbbbab94e012a4346833c.

- - - - -
be84c4b8 by Merci Jacob at 2026-02-19T15:45:26+02:00
[FIX] Fix $.buildParams on multi-entries nested objects, and nested but empty objects

- - - - -


1 changed file:

- lib/jquery_tiki/tiki-jquery.js


Changes:

=====================================
lib/jquery_tiki/tiki-jquery.js
=====================================
@@ -1489,6 +1489,7 @@ $.fn.tiki = function(func) {
         return $.service(controller, action, o);
     };
 
+    $.paramsToProcessLength = 0;
     $.buildParams = function (query, prefix, suffix, _keysNamespace = []) {
         prefix = prefix || '';
         suffix = suffix || '';
@@ -1497,29 +1498,32 @@ $.fn.tiki = function(func) {
             return query;
         }
 
-        function collectParams(input, inputPrefix, inputSuffix, keysNamespace) {
-            const params = [];
+        const params = [];
+        $.paramsToProcessLength = $.paramsToProcessLength || Object.keys(query).length;
 
-            for (const [key, value] of Object.entries(input)) {
-                if ($.isPlainObject(value)) {
-                    const nextKeysNamespace = [...keysNamespace, key];
-                    const keyNamespace = nextKeysNamespace.at(-2);
-                    const prefixInner = (keyNamespace ? `${keyNamespace}~` : '') + key + '[';
+        for (const [key, value] of Object.entries(query)) {
+            if ($.isPlainObject(value) && ! $.isEmptyObject(value)) {
+                _keysNamespace.push(key);
+                const keyNamespace = _keysNamespace.at(-2);
+                const prefixInner = (keyNamespace ? `${keyNamespace}~`: '') + key + '[';
 
-                    params.push(...collectParams(value, prefixInner, ']', nextKeysNamespace));
-                } else if (Array.isArray(value)) {
-                    value.forEach(function (arrayValue) {
-                        params.push({ [`${inputPrefix}${key}${inputSuffix}[]`]: arrayValue });
-                    });
-                } else {
-                    params.push({ [`${inputPrefix}${key}${inputSuffix}`]: value });
-                }
-            }
+                $.paramsToProcessLength += Object.keys(value).length - 1;
 
-            return params;
+                params.push(...$.buildParams(value, prefixInner, ']', _keysNamespace));
+            } else if (Array.isArray(value)) {
+                value.forEach(function (av) {
+                    params.push({[`${prefix}${key}${suffix}[]`]: av});
+                });
+                $.paramsToProcessLength--;
+            } else {
+                params.push({[`${prefix}${key}${suffix}`]: value});
+                $.paramsToProcessLength--;
+            }
         }
 
-        return collectParams(query, prefix, suffix, _keysNamespace).map(function (param) {
+        if ($.paramsToProcessLength) return params;
+
+        return params.map(function (param) {
             const k = Object.keys(param)[0];
             return k + '=' + encodeURIComponent(param[k]);
         }).join('&');



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/compare/7f17bf8664c83b78dd3fbbbab94e012a4346833c...be84c4b81eb16dea61448076d9d73d2f8532a042

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