[BUG] Adds normalize to boolean adapter#434
Conversation
|
| public function normalize(mixed $value): mixed | ||
| { | ||
| return $value !== null ? (bool) $value : null; | ||
| } |
There was a problem hiding this comment.
| public function normalize(mixed $value): mixed | |
| { | |
| return $value !== null ? (bool) $value : null; | |
| } | |
| public function normalize(mixed $value): mixed | |
| { | |
| if ($value === null) { | |
| return null; | |
| } | |
| if ($this->fieldDefinition instanceof BooleanSelect) { | |
| return $this->fieldDefinition->getDataFromResource($value); | |
| } | |
| return (bool) $value; | |
| } |
The boolean adapter is also registered for booleanSelect, which has a 3 states. Maybe something like this would be better? What do you think?
There was a problem hiding this comment.
The is no fieldDefinition value existing for the $this context. In AdapterInterface this field is private
There was a problem hiding this comment.
True, getFieldDefintion would be the way to go.
|
Could someone kindly take over this MR? - Im facing the the same issue currently |
Unfortunately I dont have the permissions to push directly to the fork, but I will discuss it internally and see what we can do. |
|
Thank you @Jonathon-Meney-Torq for the fix and analysis! Since the head branch lives on an organization-owned fork, "allow edits by maintainers" is not available and we could not push the agreed review follow-up here. We have recreated this PR upstream as #469 — your commit is included with authorship preserved, plus a follow-up commit resolving the booleanSelect tri-state point from the review thread and unit tests. Closing in favor of #469. cc @MarcoLeko |



Changes in this pull request
Fixes issue where checkbox classification store keys would fail on index update as value was being read as string instead of boolean.
Additional info
On a typical class definition a boolean field would be a tinyint and there of the correctly expected type. A classification store value is stored as a longtext and there fore interpreted as a string.