Visibility incorrectly returns false on OR logic when context missing from a different condition

Created on 29 January 2025, about 1 month ago

Problem/Motivation

Blocks incorrectly not displaying after upgrade from 2.0.3 to 2.0.4

Steps to reproduce

Set up a block with a block visibility group having 2 separate mutually exclusive conditions where only 1 must pass (ie. one condition based on content-type and one condition based on vocabulary type).

Block will not display when one condition passes because the other condition has a null context.

Proposed resolution

Check that $logic = 'and' before returning false from applyContexts() when context data is null for one condition.
Current code

Suggested code:

          // Skip when any of the contexts is not set.
          if ($logic == 'and') {
            foreach ($contexts as $context) {
              if ($context->getContextData()->getValue() === NULL) {
                return FALSE;
              }
            }
          }
πŸ› Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States debra-v

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024