From 426e846f5874240eedfb1c6460472cf750a5c851 Mon Sep 17 00:00:00 2001 From: Indelog Date: Wed, 7 Apr 2021 10:01:05 +0200 Subject: [PATCH] Fix website create/update empty otherlang Empty otherlang value was not correctly ignored. --- htdocs/website/class/website.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 1c402b82d34..966e0e8e4d8 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -185,7 +185,10 @@ class Website extends CommonObject if (is_array($tmparray)) { foreach ($tmparray as $key => $val) { // It possible we have empty val here if postparam WEBSITE_OTHERLANG is empty or set like this : 'en,,sv' or 'en,sv,' - if (empty(trim($sublang))) continue; + if (empty(trim($val))) { + unset($tmparray[$key]); + continue; + } $tmparray[$key] = preg_replace('/[_-].*$/', '', trim($val)); // en_US or en-US -> en } $this->otherlang = join(',', $tmparray); @@ -497,7 +500,10 @@ class Website extends CommonObject if (is_array($tmparray)) { foreach ($tmparray as $key => $val) { // It possible we have empty val here if postparam WEBSITE_OTHERLANG is empty or set like this : 'en,,sv' or 'en,sv,' - if (empty(trim($val))) continue; + if (empty(trim($val))) { + unset($tmparray[$key]); + continue; + } $tmparray[$key] = preg_replace('/[_-].*$/', '', trim($val)); // en_US or en-US -> en } $this->otherlang = join(',', $tmparray);