Update Drush commands for Drush 12+

Created on 26 August 2024, 22 days ago
Updated 15 September 2024, 1 day ago

Problem/Motivation

Drush 11 is EOL. Drupal 10 requires Drush 12.5+.

Drush 12 works on Drupal 10 but not Drupal 11.
Drush 13 is required for Drupal 11 but will also work on Drupal 10.2+.

https://www.drush.org/13.x/install/#drupal-compatibility

Proposed resolution

Upgrade search_api Drush commands for Drush 12+.

The big things here are to use PHP Attributes instead of Annotations for Commands, and to use autodiscovery instead of drush.services.yml, and to use autowiring instead of service injection.

These things are supported by Drush 12 and required in Drush 13.

Remaining tasks

Basic steps that apply to this module are:

  • Change namespace and class naming according to https://www.drush.org/12.x/commands/#auto-discovered-commands-psr4
  • Add use statement for Drush PHP attribute classes.
  • Use PHP attributes for Drush command definitions, as per https://www.drush.org/12.x/commands/#attributes-or-annotations
  • Do not remove the Drush annotations yet - that will make these changes easier to review and easier to fix if a problem is noticed.
  • Remove drush.services.yml and remove drush.services.yml from composer.json. Drush commands will be autoloaded.
  • Use Autowire instead of dependency injection.
  • Add parameter and return type hints to all methods. Turn on strict_types.
๐Ÿ“Œ Task
Status

Needs review

Version

1.0

Component

Drush / Rules

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States TR Cascadia

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

Merge Requests

Comments & Activities

  • Issue created by @TR
  • Pipeline finished with Canceled
    22 days ago
    Total: 294s
    #264566
  • Pipeline finished with Success
    22 days ago
    Total: 379s
    #264567
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States TR Cascadia

    There are no actual tests for the Drush commands, so the only things the tests will show are issues brought up by cspell, eslint, phpcs, and phpstan. Indeed, phpcs shows there was 1 missing space character. Fixed that.

    You can see from the changes that none of the actual command methods were modified, so they work exactly as they did before. The only thing in the patch that had a potential to cause problems was adding the parameter and return type hints, and declaring strict_types. But there were no errors in the above tests. However, each command should be manually tested to ensure there are no runtime typing problems.

  • Status changed to Needs review 22 days ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States TR Cascadia
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States TR Cascadia
  • ๐Ÿ‡ฆ๐Ÿ‡นAustria drunken monkey Vienna, Austria

    drunken monkey โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฆ๐Ÿ‡นAustria drunken monkey Vienna, Austria

    Thanks a lot for creating this issue, I had completely missed those changes in Drush. Also thanks a lot for already providing an MR with the necessary changes.
    I manually ran all the commands, and also viewed their help, and made two fixes: one arguably unrelated one to the inner workings of the sapi-i command, the other just adding descriptions for all the arguments.
    Please test/review, if no-one objects I think Iโ€™ll just merge this in a week or so.

Production build 0.71.5 2024