Skip to content

[BUG] Adds normalize to boolean adapter#434

Open
Jonathon-Meney-Torq wants to merge 1 commit into
pimcore:2.5from
TorqIT:fix/boolean-adapter-classification-store
Open

[BUG] Adds normalize to boolean adapter#434
Jonathon-Meney-Torq wants to merge 1 commit into
pimcore:2.5from
TorqIT:fix/boolean-adapter-classification-store

Conversation

@Jonathon-Meney-Torq

Copy link
Copy Markdown

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.

@sonarqubecloud

Copy link
Copy Markdown

Comment on lines +30 to +33
public function normalize(mixed $value): mixed
{
return $value !== null ? (bool) $value : null;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants