From 3c44f96f63edeb9b68bac96c263efd7f4612249f Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 14 Jun 2025 13:49:48 +0900 Subject: [PATCH] Fix empty procDocumentAddCart request (2.1.24 regression) #2568 --- common/js/common.js | 16 ++++++++++------ modules/document/document.controller.php | 23 +++++++++++++++-------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/common/js/common.js b/common/js/common.js index 9033e49e2..dda9ae1ed 100644 --- a/common/js/common.js +++ b/common/js/common.js @@ -653,7 +653,7 @@ Rhymix.ajaxForm = function(form, success, error) { * @return void */ Rhymix.checkboxToggleAll = function(name) { - if (!window[name]) { + if (typeof name === 'undefined') { name='cart'; } let options = { @@ -1457,12 +1457,16 @@ function popopen(url, target) { * @return void */ function doAddDocumentCart(obj) { - Rhymix.addedDocument.push(obj.value); + if (obj && obj.value) { + Rhymix.addedDocument.push(obj.value); + } setTimeout(function() { - exec_json('document.procDocumentAddCart', { - srls: Rhymix.addedDocument.join(',') - }); - Rhymix.addedDocument = []; + if (Rhymix.addedDocument.length > 0) { + exec_json('document.procDocumentAddCart', { + srls: Rhymix.addedDocument + }); + Rhymix.addedDocument = []; + } }, 100); } diff --git a/modules/document/document.controller.php b/modules/document/document.controller.php index 0bc2dc7c9..418857e29 100644 --- a/modules/document/document.controller.php +++ b/modules/document/document.controller.php @@ -3301,16 +3301,23 @@ class DocumentController extends Document } // Get document_srl - $srls = explode(',',Context::get('srls')); - for($i = 0; $i < count($srls); $i++) + $srls = Context::get('srls'); + if (is_array($srls)) { - $srl = trim($srls[$i]); - - if(!$srl) continue; - - $document_srls[] = $srl; + $document_srls = array_map('intval', $srls); + } + else + { + $document_srls = array_map('intval', explode(',', $srls)); + } + + $document_srls = array_unique(array_filter($document_srls, function($srl) { + return $srl > 0; + })); + if (!count($document_srls)) + { + return; } - if(!count($document_srls)) return; // Get module_srl of the documents $args = new stdClass;