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

[4.x]: craft\elements\conditions\entries\ElementCondition::matchElement() not working as expected with entry type rules #11914

Closed
ttempleton opened this issue Sep 11, 2022 · 2 comments
Assignees

Comments

@ttempleton
Copy link

What happened?

Description

When calling $condition->matchElement($entry) on a $condition of type craft\elements\conditions\entries\EntryCondition, which has a rule for which entry types match, false is always returned. This is reproducible using Neo, which implements block type filtering based on entry/category/etc. conditions, and if a block type has an entry condition rule set for entry types, that block type won't be available to use on any entry type. The block type condition settings themselves don't do anything special to change the saved values (as far as I'm aware) and the entry type UID is saved for the rule in the database. Other rules that can be used for entry conditions (e.g. the section and date created rules) are working as expected.

Please let me know if you need any other info.

Steps to reproduce

The following steps to reproduce are based on those from spicywebau/craft-neo#634.

  1. Install Neo, create a Neo field with two block types.
  2. Go to one of the block types' settings, expand the 'advanced' section to see the condition settings
  3. Under 'Entry Condition', set an entry type rule
  4. Edit an entry with the chosen entry type
  5. The block type with the condition is not visible

Expected behavior

That the scenario outlined in spicywebau/craft-neo#634 (comment) (where the entry type being compared has the same UID as is recorded in the EntryCondition) would return true.

Actual behavior

The above scenario with the matching entry type UID returns false.

Craft CMS version

4.2.3

PHP version

8.1.10

Operating system and version

macOS Monterey 12.5.1

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

  • Neo 3.3.7
@brandonkelly
Copy link
Member

Thanks for reporting that! Just fixed for the next release.

@brandonkelly
Copy link
Member

Craft 4.2.4 is tagged with that fix.

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

No branches or pull requests

3 participants