drush-ops / drush

Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt.
https://www.drush.org
2.34k stars 1.08k forks source link

Twig debug command is becoming flaky, sometimes somehow inoperable, or is misleading? #6055

Open mlncn opened 4 months ago

mlncn commented 4 months ago

Describe the bug

Twig debug output should start showing when Drush's twig:debug command is run.

To Reproduce What did you do?

Ran drush twig:debug on and twig debug output did not come on.

Tried turning it on and off, removing and adding services.yml files, and pretty much everything to no avail— except looking in Drupal's UI, where turning twig debugging on at /admin/config/development/settings worked fine.

Expected behavior

Pretty much no matter what other settings are in place, running drush twig:debug on should begin showing twig template information in HTML comments— or at least indicate an error of why it cannot.

Actual behavior

Nothing but a message " [OK] Enabled twig debug. " which was not actually true.

Workaround

Go to /admin/config/development/settings and enable "Twig development mode" and inside that "Twig debug mode" and "Disable Twig cache".

Twig debugging / caching settings added to administrative user interface | Drupal.org

System Configuration

Q A
Drush version? 13.x/12.x/11.x/10.x/8.x (please be specific, and try latest release)
Drupal version? 10.3.0
PHP version 8.1
OS? Debian trixie running DDEV 1.23.2

Additional information

This site installs from config, in case that could be a factor somehow.

gitressa commented 3 months ago

I am also seeing this. These Drush commands used to allow enabling and disabling Twig debugging, but now do nothing:

It can also be activated/deactivated with Drush:

drush state:set twig_debug 1 --input-format=integer && \
drush state:set twig_cache_disable 1 --input-format=integer && \
drush state:set disable_rendered_output_cache_bins 1 --input-format=integer && \
drush cache:rebuild

To disable debug mode in Drupal 10:

drush state:set twig_debug 0 --input-format=integer && \
drush state:set twig_cache_disable 0 --input-format=integer && \
drush state:set disable_rendered_output_cache_bins 0 --input-format=integer && \
drush cache:rebuild

From Disabling and debugging caching > Enabling Twig debugging via Drush.

I need to activate it via GUI at /admin/config/development/settings.

System Configuration

Q A
Drush version 12.5.2.0
Drupal version 10.3.1
PHP version 8.2.20
OS Debian 12 with DDEV 1.23.3
occupant commented 2 months ago

Same issue as gitressa, mlncn. The Drush commands to enable / disable twig debug are not working, either when using:

drush state:set twig_debug 0 --input-format=integer && \
drush state:set twig_cache_disable 0 --input-format=integer && \
drush state:set disable_rendered_output_cache_bins 0 --input-format=integer && \
drush cache:rebuild

or

drush twig:debug off

Disabling / enabling via the UI does work (/admin/config/development/settings).

System Configuration Q A
Drush version 12.5.3.0
Drupal version 10.3.3
PHP version 8.3.11
hudri commented 1 month ago

This commands no longer works for Drupal v10.3 and above. In version 10.3, the storage for these settings was changed from state to keyValue.

see https://www.drupal.org/project/drupal/issues/3437162 and https://www.drupal.org/node/3438802

hudri commented 1 month ago

You can set it with eval in v10.3 above, see https://drupal.stackexchange.com/a/316894/72678

gitressa commented 1 month ago

Thanks for clearing this up @hudri, I guess these files needs a PR then (maybe more?) for drush twig:debug on to work again:

gitressa commented 1 month ago

I updated the documentation at https://www.drupal.org/docs/develop/development-tools/disabling-and-debugging-caching. Thanks again @hudri!