Problem/Motivation

The audit:list, audit:run and audit:filters commands in AuditCommands extend DrushCommands and use io() and the command logger. Drush 14, which is installed for the Drupal 12 variant in GitLab CI, deprecates both: "Since drush/drush 14.0.0: Convert to a Console command and build a DrushStyle instance" and "Since drush/drush 14.0.0: Convert to a Console command and inject a Logger". See https://www.drush.org/latest/commands/

Drupal 12 core sets failOnDeprecation for PHPUnit, so these deprecations make the "phpunit (next major)" job fail even though every test passes (AuditCommandsTest and AuditCommandsKernelTest).

The conversion cannot be done yet without breaking Drupal 10 support: the Drupal 10 variant runs on PHP 8.1, where Composer installs Drush 12, and Drush 12 does not support the new Console command style.

Proposed resolution

Once the module no longer needs to support Drush 12 (for example, when Drupal 10 support is dropped after Drupal 12 is released), convert the three commands to Symfony Console commands as described in the Drush documentation, build DrushStyle and inject the logger instead of relying on DrushCommands, and update AuditCommandsTest and AuditCommandsKernelTest accordingly. The workaround in AuditCommandsTest::setUp() that gives io() a SymfonyStyle when DrushStyle is not autoloadable (Drush 12) can then be removed.

Remaining tasks

  • Decide when to drop Drush 12 / Drupal 10 support.
  • Convert the commands and update the tests.
  • Check that "phpunit (next major)" passes with no deprecations from AuditCommands.

Comments

trebormc created an issue. See original summary.

  • trebormc committed bca26ab0 on 1.x
    Issue #3626564 by trebormc: Convert the Drush commands to Symfony...
trebormc’s picture

Status: Postponed » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.