Submitted by Damien on
Tags:
Recently I was tying myself in knots trying to work out why certain blocks weren't displaying. Long story short, the problem ended up coming from a custom condition plugin that didn't cover for enough use cases.
I ended up tracking down the problem by debugging my way through the block condition logic. In BlockRepository::getVisibleBlocksPerRegion() it checks the access logic for each block
foreach ($this->blockStorage->loadByProperties(['theme' => $active_theme->getName()]) as $block_id => $block) {
/** @var \Drupal\block\BlockInterface $block */
$access = $block->access('view', NULL, TRUE);
?>
The important part here is the $access variable - that will ultimately give you the response from BlockAccessControlHandler::checkAccess() where it will say e.g. "One of the block visibility conditions ('mycondition') denied access." From there you can track down the "mycondition" plugin and see if its logic needs tweaking.