Node Type / Entity bundle conditions evaluation is wrong when context is not provided

Created on 29 October 2016, about 8 years ago
Updated 9 November 2023, about 1 year ago

Problem/Motivation

The context (entity_bundle:node) is required. This should not be the case.

Steps to reproduce

If a content type (bundle) (for example "Article") is selected and negate the condition which means the condition has to be true except the content type is equals "Article".
The problem then is if there is an entity which has not a node/content type (for example a view from the Views module) the plugin evaluate to false although the condition is given that the (not existing) node is not of content type "Article" but because the context is missing it ends in false.

Proposed resolution

- Make entity bundle context optional - setRequired to FALSE
- Make sure the entity is instanceof ContentEntityInterface for EntityBundle Plugin Condition evaluate method.
- Update tests - EntityBundleConditionTest - accordingly ... with the right context

Remaining tasks

Which merge request(s) should be used?

4610 is for 11.x and what was reviewed and should be committed.
2879 is for 10.1.x and can be closed.

Original description

In my opinion the NodeType condition plugin does not evaluate correctly. The problem is, that the context (entity:node) is required. This should not be the case.

Because if I select a content type (for example "Article") and negate the condition which means the condition has to be true except the content type is equals "Article". The problem then is if there is an entity which has not a node/content type (for example a view from the Views module) the plugin evaluate to false although the condition is given that the (not existing) node is not of content type "Article" but because the context is missing it ends in false.

The patch attached below should fix this misbehavior.

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
EntityΒ  β†’

Last updated about 10 hours ago

Created by

πŸ‡¨πŸ‡­Switzerland TiMESPLiNTER

Live updates comments and jobs are added and updated live.
  • Needs subsystem maintainer review

    It is used to alert the maintainer(s) of a particular core subsystem that an issue significantly impacts their subsystem, and their signoff is needed (see the governance policy draft for more information). Also, if you use this tag, make sure the issue component is set to the correct subsystem. If an issue significantly impacts more than one subsystem, use needs framework manager review instead.

  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs manual testing

    The change/bugfix cannot be fully demonstrated by automated testing, and thus requires manual testing in a variety of environments.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024