The current 8.x-1.x version is only compatible with Drush 8. It defines a drush cache hook which is no longer triggered in Drush 9.x and needs to be converted.
This will imply reverting #2864907: Remove composer file since Drush 9 needs a composer.json to load its services file.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | interdiff-2977745-6-8.txt | 328 bytes | fgm |
| #8 | 0001-Issue-2977745-by-fgm-add-Drush-9-support-8.patch | 2.86 KB | fgm |
| #6 | 0001-Issue-2977745-by-fgm-make-Token-compatible-with-Drush-89.6.patch | 3.43 KB | fgm |
| #3 | 0001-Issue-2977745-by-fgm-Support-Drush-9-for-cache-clear.patch | 3.71 KB | fgm |
Comments
Comment #2
fgmComment #3
fgmSuggested patch
Comment #4
webflo commented+ $types['token'] = \token_clear_cache::class;
This notation for a callable looks odd. token_clear_cache is a function not a class.
Comment #5
fgmYes, PHP syntax has these weird peculiarities. The possible upside is it allows an IDE to find the backreference from the function declaration, whereas using
"token_clear_cache"instead of\token_clear_cache::classwould not.Comment #6
fgmRerolled on current HEAD, and removed the language construct which bothered @webflo.
Comment #7
berdirHm. token_cache_clear() calls the Drupal core cache clear and resets a bunch of static caches, which is pointless in a drush call.
Meaning, this isn't token.module specific. Maybe this could just be added directly to drush if it's useful (not sure about that?) as it's really a drupal core integration? Then we'd just phase this out and eventually remove it when drush8 is no longer supported?
Comment #8
fgm@berdir: I guess you mean token_clear_cache() ? token_cache_clear() only provides a callback which happens to invoke token_clear_cache() itself.
AIUI The important part of this is the resetInfo() call at the beginning of token_clear_cache() which invalidates the "token_info" tag. Which is something one will want to do when the Drush "@hook on-event cache-clear" is triggered.
But at any rate, this is not specific to this patch: this replicates the behavior already present in Drush 8, so changing it would be off-topic for Drush 9 compatibility, would it not ?
In the meantime, rerolled because it no longer applied on HEAD after a previous fix.
Comment #9
berdirYes, but that resetInfo() API is in core and not in token module. token.module does provide a lot of additional tokens and the UI, but I'm glad for everything that doesn't need to be in this project.
My argument is that this API change of Drush 9 might be a good point to add it directly to drush instead of having to keep maintaining it here.
Comment #10
neclimdulDrive by review, it would be simpler if you reversed the if logic and only set the type when everything is true.
Comment #11
berdir#2717721: Drush commands for bulk alias updates doesn't need the composer.json part apparently?
Comment #12
fgmThe composer part used to be necessary in earlier Drush 9.x versions for Drush to find its services file (and allowed it to have a non-default name).
Maybe it stopped being required in 9.5/9.6 ?
Comment #13
berdirI still don't see why it's token that need to add it, but I suppose it doesn't hurt and to be fair, that's true for most what this module does ;)
Plus, I need a composer.json now for D9 compatibility, so cleaned up and removed the non-required parts and commited.
Comment #15
fgmThanks @Berdir. Howver, now that Drush 10 is out, it would be simple to make token compatible with Drush 10 by just modifying line 11 of composer.json from
"drush.services.yml": "^9"
to
"drush.services.yml": "^9 || ^10"
Would you commit it that change too, while you're on it ?
Comment #16
berdirDone.
Comment #18
fgmNow, /that/'s fast :-D