Closed (fixed)
Project:
Term condition
Version:
8.x-1.1
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Sep 2016 at 14:03 UTC
Updated:
24 May 2019 at 21:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
j.b commentedNot only for view pages but if i resave any blocks.
they are not displayed
Comment #3
j.b commentedmr_phillip did you find a solution for this bug ?
Comment #4
dieuweWhen saving any block, this gets added to the YAML:
I believe this "empty" snippet is what causes the blocks to be hidden from any non-node pages.
Working on a patch.
Comment #5
dieuweTerm condition is requiring all blocks to have a node context from a route. When a page does not have a node, the block is hidden because the condition will not be evaluated. So even if you left the term condition empty (null), then the block will still be hidden.
In the attached patch, we make the node context no longer required. This will give you an extra option field to select the context on the block configuration form, but "node from URL" seems to be selected by default so the overall behaviour of the module is not affected.
This change will of course cause fatal errors on non-node pages, as the function that evaluates the condition assumes a node will be present, so the second half of the patch will ensure that FALSE is returned if a node is not present. Again, this ensures normal/expected behaviour (non-node pages can obviously not have terms assigned to them and so will always return FALSE.)
Hopefully this is a satisfactory approach, but if not, then I hope it points you in the right direction.
Comment #6
dieuweI should add that all you should need to do after applying the patch is to flush the cache and all blocks should behave as expected without needing to be edited/resaved.
Comment #7
dieuweSorry, patch in #5 is malformed, this is the correct one.
Comment #8
cayenne commentedHaving a little difficulty with the patch.
Apparently, need the option of p1, rather than p0.
Once installed, it did the trick.
Comment #9
danielvezaRan this on my D8 site which had this exact problem and it solved the issue.
Comment #10
camhowardThe patch in #7 also solved the issue for me. Thanks!
Comment #11
tmountjr commentedPatch in #7 worked for me.
Comment #12
8thom commentedConfirmed patch in #7 is working nicely.
Comment #13
ckaotikWhile the proposed patch fixes the symptoms, it does not resolve the actual cause of the issue. I've attached a patch that should fix the detection of an "empty" term condition, please try that one instead.
The problem occurs because the condition is considered "not empty", even though it should be. Then it requires a node with the "" term, which fails on many pages, thus permanently breaking any block being saved with the broken term condition. If you were to uninstall the module term_condition, all those blocks would be deleted, as they incorreclty have a dependency on the module.
Comment #14
criscomThe patch in #13 did not work for existing blocks. After applying patch in #7 it worked.
Comment #15
giorgosk#13 did not work for existing blocks even after resaving their configuration manually
#7 worked after clearing the cache
I believe #7 should be reviewed and tested
Comment #16
jastraat commented+1 for patch #7
Comment #17
danielvezaHaving reviewed the issue some more and doing some testing - I can see the issue is solved by patch #7 and that patch is needed, but patch #13 is also correct and needs to be fixed as well.
As Ckaotik says, without his patch any new blocks created are saved with a term of "". His issue fixes that, so only blocks with term conditions are effected by this module rather than all of them.
I've combined these patches into two and it's passed my testing. If someone could test this patch and verify that would be great. Otherwise I'll commit in a day or two.
Comment #19
danielvezaThanks all!