context_all, context_any, user_status condition plugins create unnecessary config and dependency on Context

Created on 9 August 2021, over 3 years ago
Updated 15 September 2023, about 1 year ago

Problem/Motivation

Since the addition of User, Context (all) and Context (any) conditions in 4.0, Context now adds configuration for all these conditions on block creation/update, even if no conditions are specified. This results in an unnecessary dependency on Context.

The extraneous config/dependency have no immediate effect, but if Context is subsequently uninstalled, every block config added or updated since Context 4.0 was enabled on the site will be deleted.

Steps to reproduce

  • Add a new block with no conditions.
  • Export configuration.
  • Note that the resulting config file has configuration for all three context-related conditions, as well as a dependency on context.

The issue occurs when existing blocks are updated as well:

  • Open block config for an existing block that has no context-related conditions.
  • Save the block config without making any changes.
  • Export configuration.
  • Examine the resulting config file and note the new context config entries and dependency.

Below is an example from my site that resulted from adding a 'Powered by Drupal' block with no conditions at all:

uuid: xxx
langcode: en
status: true
dependencies:
  module:
    - context
    - system
  theme:
    - xxx
id: poweredbydrupal_2
theme: xxx
region: brandbar_left
weight: 0
provider: null
plugin: system_powered_by_block
settings:
  id: system_powered_by_block
  label: 'Powered by Drupal'
  provider: system
  label_display: '0'
visibility:
  user_status:
    id: user_status
    user_status:
      viewing_profile: '0'
      logged_viewing_profile: '0'
      own_page_true: '0'
      field_value: '0'
    user_fields: uid
    negate: false
    context_mapping:
      user: '@user.current_user_context:current_user'
  context_all:
    id: context_all
    values: ''
    negate: null
  context:
    id: context
    values: ''
    negate: null

Proposed resolution

Don't save any context config if no context conditions are set to avoid creating a dependency. Details TBD.

Remaining tasks

TBD

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States justcaldwell Austin, Texas

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