Problem/Motivation
The context (entity_bundle:node) is required. This should not be the case.
Steps to reproduce
Select a content type (bundle) (for example "Article").
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
| Comment | File | Size | Author |
|---|---|---|---|
| #42 | 2823432-nr-bot.txt | 90 bytes | needs-review-queue-bot |
Issue fork drupal-2823432
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
chi commentedComment #3
chi commentedComment #4
TiMESPLiNTER commentedAny news about this issue? What work is required to bring this fix into the next release?
Comment #8
borisson_This patch doesn't seem to have any tests. Let's start by adding those.
Comment #10
antonnaviHi all here!
I got the same issue on my project, but this patch didn't help me. I modified it to cover my issue case too.
Comment #12
andypostComment #13
antonnaviComment #16
andypostComment #18
hardik_patel_12 commentedRe-rolled against 9.1.x-dev.
Comment #19
hardik_patel_12 commentedKindly ignore previous patch forgot to remove
"node" = @ContextDefinition("entity:node", label = @Translation("Node"))Comment #23
andypostRelated issue committed
Comment #24
meenakshi_j commentedFixed the fails #19
Comment #25
berdirWhat #23 was trying to say is that this now also needs to update the new EntityBundle condition accordingly.
Comment #28
damienmckennaRelated: #2887071
Comment #32
vasikeThere is a new MR for D10, but only for Entity bundle condition, as "Node Type" is history.
However this will not solve "all problems" with the condition that have negate option set to TRUE.
For this i think we need to link this with https://www.drupal.org/project/drupal/issues/2535896
And of course any suggestions for tests that are required ... could help.
Comment #33
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #need-reveiw-queue. We are working to keep the size of Needs Review queue [2700+ issues] to around 200, following Review a patch or merge require as a guide.
Moving back to NW for the tests.
Hiding the patches as the MR seems to be the approach going forward. Appears to be failures in the MR.
Tagging for IS update to follow the standard template.
Comment #34
vasike- Rebase the MR
- Update - Small test for missing context for EntityBundle condition - without this update will fail.
Comment #35
vasikeIt seems the latest updates revealed issue with testing the block with node bundle condition - missing route context ...
Now it should be "completed".
Comment #36
smustgrave commentedSeems tests have been added but IS update is still needed
Did not test yet.
Comment #38
vasikeupdatet summary and MR rebased.
Comment #39
smustgrave commented11.x is the latest development branch. MR should probably be updated to point to that.
Comment #40
smustgrave commentedRan the tests locally to make sure they failed without the fix
Behat\Mink\Exception\ElementNotFoundException : Form field with id|name|label|value "visibility[entity_bundle:node][context_mapping][node]" not found.
and
Drupal\Component\Plugin\Exception\ContextException : The 'entity:entity_test_with_bundle' context is required and not present.
Which is good
Thanks for updating the issue summary, removing that tag
Think this 7 year issue is ready for committer review.
Comment #41
quietone commentedDoing RTBC triage.
The issue summary is up to date and I see that a remaining task is 'code review'.
The issue title was changed on GitLab but that is not reflected here. Can someone fix that?
Reading through the comments there is work on the patch, addition of tests and rerolls but there is no code review that I can find. I do see that @smustgrave ran a fail test locally, that is good to know. But still in need of eyes on the code.
Comment #42
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #44
vasikenew MR for 11.x available and passed, so, i think we're back to Needs review
Comment #45
smustgrave commentedAll green for 11.x so think this is good to go back.
Comment #46
xjmThere are two open merge requests in the issue summary. Please close the non-canonical one, or if you don't have permission to close it, document which should be closed in an issue comment and the IS so a committer can close it for you. Thanks!
Comment #47
smustgrave commentedUpdated proposed section
Comment #48
xjmThanks @smustgrave. I think maybe we should put in at least an h4 for this, or possibly add it under a separate h3, so that it's obvious on scanning. I updated the summary accordingly.
Comment #50
xjmPosted some comments on the MR. I'd also like to see some manual testing documented for node and non-node entity bundles. Thanks!
Comment #51
timohuismanAttached is a snapshot of the current state of MR 4610, so it can be safely used with composer-patches.
I came across this issue through #3264843: Add support for negating node type(content type) condition for block visibility, which seems to work in combination with MR 4610.
However, I've tried to test MR 4610 standalone, but I'm not sure what it should resolve. If I understand this issue correctly the MR should resolve the fact that blocks are hidden on non-node-type routes when there is a node bundle condition configured. I've add a condition for "Article" nodes to the page title block, visited a non existent page so I could see the 404 page but the page title was still hidden.
Comment #53
oily commentedComment #54
oily commentedComment #55
oily commentedEdited the issue summary. Simplified the description and steps to reproduce and remove duplicate sections.
Okay, just read all comments and realised the issue summary has been edited already. Please revert my changes if they aren't useful.
Comment #56
oily commentedRebased.
There are still code comments to be resolved in the MR especially in the tests. The issue tags show other tasks to be completed.
Comment #57
oily commentedComment #58
vasikeMR updated with latest 11.x + some feedback for MR review.
Let's try again a review. thanks
Comment #59
xjmAmending attribution.
Comment #60
smustgrave commentedBeen over 4 months and no sub-maintainer has freed up so lets bump to framework managers.
Comment #62
acbramley commentedSaw this pop up in the needs review slack - my first thoughts are that this may cause pretty major issues for existing sites (e.g a bunch of blocks may start displaying where they didn't before).
Comment #63
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.