Reviewed & tested by the community
Project:
Context
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Apr 2013 at 19:53 UTC
Updated:
26 Dec 2020 at 05:16 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
eanushan commentedI can confirm this bug exists in 7.22 as well in a slightly different case. If I set a block to only be visible to certain role types, the code in the block is executed for all roles, but the output is simply hidden for the roles that are not checked. This has some strange side effects like the one mentioned by the bug reporter as well as performance implications if there is a particularly bulky module that should only be visible to administrators for example.
This happens in Drupal core though, so maybe we should move the ticket over there.
Comment #2
eanushan commentedComment #3
David_Rothstein commentedI wasn't able to reproduce this with Drupal core alone, and don't see how it could be? (The code to hide blocks that are not supposed to be visible happens in block_block_list_alter() which is invoked by _block_load_blocks() right after the blocks are loaded from the database, and therefore well before they are rendered.)
If anyone can find reproducible steps to hit this problem with Drupal core alone, feel free to move it back though.
Comment #4
eanushan commentedAh, it seems the reason this is occuring is because the block in question was implementing hook_node_view. Even if the block is not visible, the hook will be executed. I think this is as expected, so indeed, it is not a Drupal core bug.
Comment #5
eanushan commentedComment #6
mavrom commentedHi EAnushan,
Here is a very simple way to reproduce the bug:
Use Drupal 7.23, latest context module version, and devel
1) Create a simple block using Drupal UI with the following body (set filter to PHP code)
2) Use the bartik theme and place the block to second sidebar (every where in drupal I expect to see the block and the dpm message)
3) Use the context module and
-Action: a particular path (i.e node/6)
-Reaction: Disable Region second sidebar
You will notice, that although the block is not shown, the dpm message still appears in path node/6.
I wouldn't expect to see the dpm message
Comment #7
mavrom commentedI set the status to active, since I think this worth to check
Comment #8
artem_sylchukFaced the same issue. Wouldn't this help?
Comment #10
artem_sylchukComment #11
loze commentedThis was my attempt at fixing this
I've been using this patch for a while now in production. It seems to do the trick.
Comment #12
loze commentedComment #13
bzoks commentedI tested both patches and by using test procedure from post #6 patch from #8 works correctly, and patch under #11 does not.
I, therefore, suggest accepting patch #8.
Comment #14
loze commentedThis is happening on the D8 version as well.
To reproduce:
Not sure if I should create a separate issue for this.
Comment #15
loze commentedSorry, I was mistaken. Ignore my last comment.