Drush 12 compatibility

Created on 15 April 2024, 2 months ago
Updated 27 June 2024, about 24 hours ago

Problem/Motivation

Drush 12 changes the way it injects services. In #3078507 , some refactoring was done to make the Drush commands available in the main module (purge). To make my custom code work (calling \Drupal::service('purge_drush.queue_commands');), I did this naive change of copying all service definitions from drush.services.yml to services.yml and all Drush commands under `src/Drush/Commands`. I also updated the class namespaces in drush.services.yml

Steps to reproduce

Install Drush 12. Notice that the services defined in `drush.services.yml` in the module suddenly don't work.

Proposed resolution

Make Drush commands compatible with Drush 12.

Remaining tasks

None.

User interface changes

None.

API changes

The services in (current) drush.services.yml in the module will be available globally in Drupal.

Data model changes

None.

Feature request
Status

Fixed

Version

3.0

Component

Code

Created by

🇫🇮Finland kekkis Pirkkala

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

Merge Requests

Comments & Activities

  • Issue created by @kekkis
  • 🇫🇮Finland kekkis Pirkkala

    Fixing Version info.

  • Merge request !38Drush 12 compatibility → (Merged) created by kekkis
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    last update 2 months ago
    610 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 5.7
    last update 2 months ago
    503 pass, 18 fail
  • Issue was unassigned.
  • Status changed to Needs review 2 months ago
  • 🇫🇮Finland kekkis Pirkkala

    An open and honest question in addition to the one in the IS: would we want to opt for auto-wiring instead of adding the create methods? It's the new in, hip and pop thing available in Drush 12.5. At least using create methods gives us a little more backwards compatibility.

  • Status changed to Needs work about 2 months ago
  • 🇫🇮Finland sokru

    Thanks for this! Requested few changes. I suggest we keep compatibility for drush v11.

  • 🇺🇸United States japerry KVUO

    To get included in the 8.x-3.x version of purge, it will need to NOT use the autowiring functionality. It appears we will need to roll a new major version of purge to accommodate many issues that have been accumulating over the past few months, but won't happen until after Drupal 11.

  • Status changed to Needs review 2 days ago
  • 🇫🇮Finland kekkis Pirkkala

    @japerry, I have pushed changes in the MR now. Please review again. As you can see in the comments, I also manually tested with the two combos that IMO make some kind of sense: Drupal 10.1+Drush 11 and Drupal 10.2+Drush 12. But as I wrote this note, I thought of yet another combo that is sensible in some cases: Drupal 10.1 + Drush 12. Here's the output for that test, which also indicates that the combination works ok with the branch:

    $ ddev drush -vvv p:diagnostics
     [preflight] Config paths: /var/www/html/vendor/drush/drush/drush.yml
     [preflight] Alias paths: /var/www/html/web/drush/sites,/var/www/html/drush/sites
     [preflight] Commandfile search paths: /var/www/html/vendor/drush/drush/src
     [debug] Bootstrap further to find p:diagnostics [0.32 sec, 2.63 MB]
     [debug] Trying to bootstrap as far as we can [0.32 sec, 2.63 MB]
     [info] Drush bootstrap phase: bootstrapDrupalRoot() [0.32 sec, 2.64 MB]
     [info] Change working directory to /var/www/html/web [0.32 sec, 2.64 MB]
     [info] Initialized Drupal 10.1.8 root directory at /var/www/html/web [0.32 sec, 2.64 MB]
     [info] Drush bootstrap phase: bootstrapDrupalSite() [0.32 sec, 2.77 MB]
     [debug] Could not find a Drush config file at sites/default/drush.yml. [0.32 sec, 2.84 MB]
     [info] Initialized Drupal site purge-test-10-1-drush-12.ddev.site at sites/default [0.32 sec, 2.84 MB]
     [info] Drush bootstrap phase: bootstrapDrupalConfiguration() [0.32 sec, 2.84 MB]
     [info] Drush bootstrap phase: bootstrapDrupalDatabase() [0.33 sec, 3.03 MB]
     [info] Successfully connected to the Drupal database. [0.33 sec, 3.02 MB]
     [info] Drush bootstrap phase: bootstrapDrupalFull() [0.33 sec, 3.03 MB]
     [debug] Start bootstrap of the Drupal Kernel. [0.33 sec, 3.02 MB]
     [debug] Finished bootstrap of the Drupal Kernel. [0.35 sec, 3.7 MB]
     [debug] Loading drupal module drush commands & etc. [0.35 sec, 3.7 MB]
     [debug] Found drush.services.yml for purge Drush commands [0.35 sec, 3.71 MB]
     [debug] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeCommands [0.37 sec, 4.52 MB]
     [debug] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeCommentsCommands [0.37 sec, 4.52 MB]
     [debug] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeSessionsCommands [0.37 sec, 4.52 MB]
     [debug] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeUserFieldsCommands [0.37 sec, 4.53 MB]
     [debug] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeUserTableCommands [0.37 sec, 4.54 MB]
     [debug] Add a commandfile class: Drupal\purge\Drush\Commands\DebugCommands [0.37 sec, 4.54 MB]
     [debug] Add a commandfile class: Drupal\purge\Drush\Commands\DiagnosticsCommand [0.37 sec, 4.55 MB]
     [debug] Add a commandfile class: Drupal\purge\Drush\Commands\InvalidateCommand [0.37 sec, 4.55 MB]
     [debug] Add a commandfile class: Drupal\purge\Drush\Commands\ProcessorCommands [0.37 sec, 4.56 MB]
     [debug] Add a commandfile class: Drupal\purge\Drush\Commands\PurgerCommands [0.37 sec, 4.58 MB]
     [debug] Add a commandfile class: Drupal\purge\Drush\Commands\QueueCommands [0.37 sec, 4.61 MB]
     [debug] Add a commandfile class: Drupal\purge\Drush\Commands\QueuerCommands [0.37 sec, 4.64 MB]
     [debug] Add a commandfile class: Drupal\purge\Drush\Commands\TypesCommand [0.37 sec, 4.65 MB]
     [debug] Done with bootstrap max in Application::bootstrapAndFind(): trying to find p:diagnostics again. [0.42 sec, 6.97 MB]
     [info] Starting bootstrap to none [0.43 sec, 7.09 MB]
     [info] Drush bootstrap phase 0 [0.43 sec, 7.09 MB]
     [info] Try to validate bootstrap phase 0 [0.43 sec, 7.09 MB]
     [error]  diagnostics: ERROR: Purgers: There is no purger loaded which means that you need a module enabled to provide a purger plugin to clear your external cache or CDN. [0.44 sec, 7.45 MB]
     -------------------- ------------------------------------------------------------------------- ---------------------------------------- ----------
      Title                Recommendation                                                            Value                                    Severity
     -------------------- ------------------------------------------------------------------------- ---------------------------------------- ----------
      Queuers              Queuer for the 'drush p:queue-add' command.                               Drush p:queue-add                        OK
      Page cache max age   Your site instructs external caching systems not to cache anything. Not   no caching                               WARNING
                           only does this make cache invalidation futile, it is also a great
                           danger to your website as any form of traffic can bring it down
                           quickly!
      Capacity             There is no purging capacity available.                                   0                                        WARNING
      Queue size           Your queue is empty!                                                      0                                        OK
      Purgers              There is no purger loaded which means that you need a module enabled to                                            ERROR
                           provide a purger plugin to clear your external cache or CDN.
      Processors           You have multiple processors working the queue.                           Drush p:queue-work, Drush p:invalidate   OK
     -------------------- ------------------------------------------------------------------------- ---------------------------------------- ----------
    
  • 🇫🇮Finland kekkis Pirkkala

    Updated issue summary.

  • Pipeline finished with Skipped
    about 24 hours ago
    #209310
  • Status changed to Fixed about 24 hours ago
  • 🇺🇸United States japerry KVUO

    Looks good! Tested against D9, 10, and 11 with Drush 10, 11, and 13. I presume 12 should work inbetween ;)

    Committed.

Production build 0.69.0 2024