From d0f0d7205d124261a34d25c8153f352b3a8bd022 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 9 Oct 2024 00:34:20 +0900 Subject: [PATCH] Improve backward compatibility with legacy |@| encoding --- modules/extravar/models/Value.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/extravar/models/Value.php b/modules/extravar/models/Value.php index 6ff92b42c..649490832 100644 --- a/modules/extravar/models/Value.php +++ b/modules/extravar/models/Value.php @@ -236,8 +236,22 @@ class Value */ public function validate($value): ?BaseObject { - $is_array = is_array($value); - $values = is_array($value) ? $value : [$value]; + // Take legacy encoding into consideration. + if (is_array($value)) + { + $is_array = true; + $values = $value; + } + elseif (str_contains($value, '|@|')) + { + $is_array = true; + $values = explode('|@|', $value); + } + else + { + $is_array = false; + $values = [$value]; + } // Check if a required value is empty. if ($this->is_required === 'Y') @@ -355,10 +369,12 @@ class Value { $values = explode('|@|', $value); } + /* elseif (str_contains($value, ',') && $type !== 'kr_zip') { $values = explode(',', $value); } + */ else { $values = [$value];