Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type comparison in element condition rules #11451

Merged
merged 4 commits into from
Jun 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@
- Fixed a bug where User Group condition rules set to the “is not one of” operator weren’t being applied to individual elements correctly. ([#11444](https://github.com/craftcms/cms/discussions/11444))
- Fixed a JavaScript error that occurred on element indexes for users that didn’t have permission to edit any sites.
- Fixed a bug where users without permission to create new entries in a section could duplicate existing entries. ([#11447](https://github.com/craftcms/cms/pull/11447))
- Fixed a bug where element selection condition rules weren’t working if an element ID was provided. ([#11451](https://github.com/craftcms/cms/pull/11451))

## 4.0.4 - 2022-06-03

4 changes: 2 additions & 2 deletions src/base/conditions/BaseElementSelectConditionRule.php
Original file line number Diff line number Diff line change
@@ -190,14 +190,14 @@ protected function matchValue(mixed $value): bool
}

if (is_numeric($value)) {
return (int)$value === $elementId;
return (int)$value === (int)$elementId;
Copy link
Member Author

Choose a reason for hiding this comment

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

$elementId can be a string.

}

if (is_array($value)) {
foreach ($value as $val) {
if (
$val instanceof ElementInterface && $val->id === $elementId ||
is_numeric($val) && (int)$val === $elementId
is_numeric($val) && (int)$val === (int)$elementId
) {
return true;
}