Skip to content

Commit 49f8fc0

Browse files
committed
fix(dropdownfield): prevent language switching and log error
1 parent a9e6cbc commit 49f8fc0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

inc/field/dropdownfield.class.php

+9-4
Original file line numberDiff line numberDiff line change
@@ -700,10 +700,6 @@ public function parseObjectProperties(
700700
// $questionID = $question->fields['id'];
701701
$questionID = $this->getQuestion()->getID();
702702

703-
// We need english locale to search searchOptions by name
704-
$oldLocale = $TRANSLATE->getLocale();
705-
$TRANSLATE->setLocale("en_GB");
706-
707703
// Load target item from DB
708704
$itemtype = $this->question->fields['itemtype'];
709705

@@ -712,6 +708,10 @@ public function parseObjectProperties(
712708
return $content;
713709
}
714710

711+
// We need english locale to search searchOptions by name
712+
$oldLocale = $TRANSLATE->getLocale();
713+
$TRANSLATE->setLocale("en_GB");
714+
715715
$item = new $itemtype;
716716
$item->getFromDB($answer);
717717

@@ -726,6 +726,11 @@ public function parseObjectProperties(
726726
// Convert Property_Name to Property Name
727727
$property = str_replace("_", " ", $property);
728728
$searchOption = $item->getSearchOptionByField("name", $property);
729+
if (count($searchOption) == 0) {
730+
trigger_error("No search option found for $property", E_USER_WARNING);
731+
$TRANSLATE->setLocale($oldLocale);
732+
return $content;
733+
}
729734

730735
// Execute search
731736
$data = Search::prepareDatasForSearch(get_class($item), [

0 commit comments

Comments
 (0)