diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..a2dfb351a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +Master branch +============= + +- fix error on export: error when field definition has changed + diff --git a/CustomFields/CustomFieldChoice.php b/CustomFields/CustomFieldChoice.php index 2c0ea0fd4..8996aa1c3 100644 --- a/CustomFields/CustomFieldChoice.php +++ b/CustomFields/CustomFieldChoice.php @@ -361,6 +361,16 @@ class CustomFieldChoice extends AbstractCustomField } } + /** + * Return true if the choice given in $choiceSlug is checked inside $data. + * + * Used in list exports. + * + * @param CustomField $cf + * @param string $choiceSlug the slug of the choice we want to know if it was checked + * @param array|string $data the data of the field + * @return boolean + */ public function isChecked(CustomField $cf, $choiceSlug, $data) { if ($data === null) { @@ -369,15 +379,15 @@ class CustomFieldChoice extends AbstractCustomField if ($cf->getOptions()[self::MULTIPLE]) { if ($cf->getOptions()[self::ALLOW_OTHER]) { - return \in_array($choiceSlug, $data['_choices']); + return \in_array($choiceSlug, $this->deserialize($data, $cf)['_choices']); } else { - return \in_array($choiceSlug, $data); + return \in_array($choiceSlug, $this->deserialize($data, $cf)); } } else { if ($cf->getOptions()[self::ALLOW_OTHER]) { - return $data['_choices'] === $choiceSlug; + return $this->deserialize($data, $cf)['_choices'] === $choiceSlug; } else { - return $data === $choiceSlug; + return $this->deserialize($data, $cf) === $choiceSlug; } } }