Block Remains Visible on Homepage When Associated 'Context (All)' Is Disabled

Created on 28 January 2024, 10 months ago
Updated 30 January 2024, 10 months ago

Problem/Motivation

When a block is placed via 'Block layout' with 'Context (All)' condition set, it continues to display on the homepage even if the specified context is disabled.

Steps to reproduce

  1. Navigate to 'Block layout' (Admin > Structure > Block layout).
  2. Create a new block and place it on the homepage. Verify it's visible on the homepage as expected.
  3. Create a new context named 'Test context' and configure it to be active for logged-in users.
  4. Set the visibility of the newly created block to 'Context (All)' and set the value as 'test_context'. The block should still be visible on the homepage, as expected.
  5. Disable 'Test Context'. The block should no longer be visible on the homepage.

Expected Behavior:

The block should not be displayed on the homepage when its associated context is disabled.

Actual Behavior:

The block remains visible on the homepage even when the associated context is disabled.

Proposed resolution

In ContextAll.php, modify the condition check to properly account for disabled contexts. Change:

if (!$this->contextManager->evaluateContextConditions($required_context) && !$required_context->disabled()) {
  return FALSE;
}

To:

if (!$this->contextManager->evaluateContextConditions($required_context) || $required_context->disabled()) {
  return FALSE;
}
🐛 Bug report
Status

Needs review

Version

5.0

Component

Code

Created by

🇿🇦South Africa willemviljoen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024