Fix website create/update empty otherlang

Empty otherlang value was not correctly ignored.
This commit is contained in:
Indelog 2021-04-07 10:01:05 +02:00
parent 17fa9559a3
commit 426e846f58

View File

@ -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);