Provide Drush command output when enforcing configuration via cache rebuild

Created on 10 May 2023, over 1 year ago
Updated 17 May 2023, over 1 year ago

Problem/Motivation

As a follow-up to Provide Drush command to enforce configs Fixed , we'd like to provide some kind of feedback when running Drush commands (such as drush cache:rebuild) if we do a configuration enforcement (or don't because of maintenance mode).

Steps to reproduce

Run drush cache:rebuild --verbose

See no mention of configuration being enforced or similar.

Proposed resolution

I reached out on the Drupal.org Slack and was pointed to the fact that Drush now supports adding custom loggers so that would be one way we could output stuff to console.

Another way would be to add a hook to the Drush cache rebuild command and output our console messages that way. This second method might be problematic if we just output a message without it checking that we did indeed do an enforce. One way around this would be to instead detect in places where we would do an enforce (e.g. \hook_rebuild()) if we're running via Drush (preferably without requiring Drush as a dependency but just checking if a service is present or something like that) and not do the enforcement at all in that case; instead we run the enforcement in the Drush hooks we implement, e.g. drush cache:rebuild, and output the console message that way; this ensures that if there's an error in enforcing preceding the message, we don't erroneously output something like "configuration was enforced" when it had in fact not been.

Remaining tasks

Move enforcement stuff and logging to services or otherwise abstract them so you provide where to output messages and just call a single thing, both from \hook_rebuild() and drush cache:rebuild.

User interface changes

TBD.

API changes

TBD.

Data model changes

TBD.

Feature request
Status

Active

Version

1.0

Component

User interface

Created by

🇨🇦Canada ambient.impact Toronto

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

Comments & Activities

Production build 0.71.5 2024