Problem/Motivation
CTools and Rules both add additional contextual condition plugins. Core's block visibility UI does not get conditions based on available contexts and instead simply asks for all Conditions.
Proposed resolution
Update the block form to ask the ConditionManager for only contextually relevant plugins instead of all plugins.
Remaining tasks
- Patch
- Review
- Commit
User interface changes
This should appropriately reduce the number of conditions displayed in the block placement UI which will likely fix some issues seen when installing various contrib modules like CTools and Rules. No functional changes though.
API changes
None
Data model changes
None
Original Report
CTools are creating context for every existing entity which results in duplicated entries in the block form. Instead of doing this full-in, it should see if there aren't already contexts defined by other modules for their entities to prevent this.


| Comment | File | Size | Author |
|---|---|---|---|
| #23 | interdiff-2632434-19-23.txt | 2.53 KB | johnchque |
| #23 | conditions_are_not-2632434-23.patch | 2.89 KB | johnchque |
| #23 | conditions_are_not-2632434-23-test-only.patch | 2.1 KB | johnchque |
| #19 | conditions_are_not-2632434-19.patch | 3.13 KB | johnchque |
| #19 | conditions_are_not-2632434-19-test-only.patch | 2.34 KB | johnchque |
Comments
Comment #1
Anonymous (not verified) commentedivanjaros created an issue. See original summary.
Comment #2
Anonymous (not verified) commentedComment #3
eclipsegc commentedThis is actually a core bug and stems from the fact that the BlockForm asks for all conditions regardless of its ability to satisfy their contexts. Easily fixed though.
Eclipse
Comment #4
eclipsegc commentedAlso, this is an outright bug in 8.0.x and doesn't change apis or anything so I think this can be safely done in 8.0.x.
Eclipse
Comment #5
eclipsegc commentedComment #6
tim.plunkettNo comment on 8.0.x vs 8.1.x, just putting it in the right place.
Also, for anyone wondering where that value comes, it's in the same class:
Comment #7
dawehnerComment #8
berdirNote that there are really two things here.
First is the problem that ctools adds all those conditions that then show up even if context for them is missing. The patch above fixes that.
However, content types are still duplicated. Because ctools adds a second one, with a different name. Does the one in ctools offer any benefit over the one in core? I don't think so, so I think we should exclude that one from being defined in ctools?
Comment #9
eclipsegc commentedOr ctools should override the node_type condition in favor of the generic one. The ctools one does actually have some additional functionality that tracks constraints based upon context. I'll look into it.
Eclipse
Comment #10
Anonymous (not verified) commentedWhat would be the recommended quickfix for now? I cannot let my users see this mess, it would be too confusing for them so I have to remove those ctools tabs asap.
--
Looks like hook_condition_info_alter does the trick just fine.
Comment #11
eclipsegc commentedI'd apply the patch from 3.
Comment #12
Anonymous (not verified) commentedSeems like I have no choice since my solution "broke" Pathauto.
--
Even with that patch is see node bundles twice.
Comment #13
eclipsegc commentedYes, that's exactly berdir's comment from 8.
Eclipse
Comment #14
berdirFor which he also already openend an issue for: #2669758: Switch bundle condition for nodes to node_type instead of entity_bundle:node. Patches welcome.
Comment #15
eclipsegc commentedComment #18
johnchqueWill upload a patch with tests soon.
Comment #19
johnchqueTests added. This should make it fail.
Comment #20
tim.plunkettThis came up again in #2811519: Blocks do not appear after being placed with the Rules module enabled (or other missing schemata for Condition plugins).
Comment #22
berdirTests that conditions...
no existing => missing.
Why is this in a views tests? Should be in one of the tests in block.module IMHO.
Condition that requires a non-existent context.
Comment #23
johnchqueChanges made based on comment above.
Comment #25
berdirThat works for me.
Removed the needs screenshots tag, I think it is pretty obvious. Having ctools enabled adds a bunch of additional vertical tabs that actually don't work. This patch hides those that wouldn't work because nobody provides a vocabulary, a block_content or whatever to get the bundle from. Note that there are still two content type conditions, that we can't fix in core as ctools adds a duplicate and it has context.
That means we need to fix that in ctools, not in core.
Comment #29
catchCommitted/pushed to 8.3.x and cherry-picked to 8.2.x, thanks!
Comment #30
eclipsegc commentedCherry-picked ++
Comment #32
idcm commentedI installed the 3.0 version, assuming this issue had been resolved. It is still showing the extra content types vertical tab in blocks.
I am on 8.3.3. My friends are on 8.3.4. We each see it.
Comment #33
berdirYes, because both are content type, and there is a content available. What this fixed is that it also shows vocabulary, block content type, and many other vertical tabs.
This is something that only ctools module can solve, as it defines a second condition with a different name. Or when it moves to core, in #1932810: Add entity bundles condition plugin for entities with bundles.