Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
Drush 9 introduces an entirely new format for commands, and stops supporting the long-standing (plugin).drush.inc after 9.0.0-beta4, so the commands need to be ported to the new format.
https://weitzman.github.io/blog/port-to-drush9
http://nuvole.org/blog/2017/oct/13/how-maintain-drush-commands-drush-8-a...
Comment | File | Size | Author |
---|---|---|---|
#56 | 2916800-56.patch | 2.75 KB | jrockowitz |
| |||
#54 | 2916800-54.patch | 2.77 KB | jrockowitz |
| |||
#51 | 2916800-51.patch | 616 bytes | jrockowitz |
#47 | 2916800-47.patch | 2.72 KB | jrockowitz |
| |||
#41 | 2916800-41.patch | 130.84 KB | jrockowitz |
|
Comments
Comment #2
GrimreaperComment #3
GrimreaperTrying to make a first patch.
Comment #4
GrimreaperHere is a first patch for the webform:composer:update command.
Currently the only one I used.
It is a quick and dirty patch, but I need this command on projects.
Comment #5
GrimreaperSorry wrong patch.
Comment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@Grimreaper The challenge is going to be supporting Drush 8.x and Drush 9.x. I might need to refactor all the existing drush commands and move as much of the business logic as possible into a reusable service.
Comment #7
Grimreaper@jrockowitz: I totally agree. And also supporting Drupal Console as Config split does by the way. But I required the command webform:composer:update to be usable now. So I made this quick and dirty patch.
Comment #8
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedConfig Split is great an example. If anyone else has examples of modules that support Drush9 and DrupalConsole, please post them here.
Comment #9
NickDickinsonWildeComment #10
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@NickWilde Thanks. Ping me on Drupal Slack if you have any questions.
Comment #11
NickDickinsonWildeStill, rough and needs more testing (haven't got to back-testing the changes on the old Drush code.
However, I'm probably not going to get more work on this done for a few days so here's my WIP.
Comment #12
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@Nick Wilde No problem. It is a good start.
I think we need to look at http://cgit.drupalcode.org/config_split/tree/src/ConfigSplitCliService.php and consider moving DrushHelper.php into WebformCliService.php service. The huge perk of a using a service is people can extend it.
Comment #13
NickDickinsonWildeOkay, this is now ready for a solid review/testing.
A few notes:
Drush make has been removed in Drush 9.x. Running `drush wfld` will print an error message to that affect.
webform-docs I didn't really test. I'll get tidy installed later and do so.
webform-generate I haven't done (haven't checked if the devel module has a Drush 9 option yet)
All other commands are converted with mostly equivalent functionality/interface.
Comment #14
NickDickinsonWildeComment #15
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedMy heart sank when I realized that drush make is no longer supported, partially cause I like the simplicity of Drush's YAML make file vs composers JSON files and secondly because my main client is on D8 but they are not yet ready to stop using Drush make.
Anyway, I need to setup my system to support Drush 8 and 9 concurrently. I am sure it is no problem. I am trying to take a much-needed break for the rest of the year. This will be one of my first major tasks of the New Year.
@NickWilde Thanks for helping push this forward and happy New Year.
Comment #16
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI am going to start reviewing this patch.
Comment #17
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI am seeing maintainability issues between the Drush 8 and 9 commands because there are too many changes being made when the Drush 8 commands are being converted to Drush 9.
For example...
Drush 8 uses `drush webform-export WEBFORM_ID` and Drush 9 is now using `drush webform-export --webform-id=WEBFORM_ID`
The `drush webform-purge` command now has dedicated drush 8 and 9 code.
I also think the Drupal community needs some code generation tools to help with the conversion. We should be able to use webform_drush_command() to generate a complete scaffold for the WebformCommands.
So far no one has come up with generic helper/bridge class that makes it easy to port and maintain Drush 8 and Drush 9 commands.
@NickWilde I really appreciate you starting to work on this. I might have to reapproach this problem and solution. I am absolutely going to use your code as a reference.
Comment #29
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedThe attached patch uses some PHP magic to create the central CLI service that supports both Drush 8 and 9. There is now a Drush command to generate webform.drush.inc and WebformCommands. My goal is to get a working and maintainable MVP.
@NickWilde I am sorry that I did not scope out this work before letting you start working on it. The lesson I learned is to push everyone including myself to estimate before taking on any big issue/ticket.
I hope once you review the patch and change record you can see how my approach makes it easier for us to maintain support for Drush 8.x and 9.x. I also made very few changes to the original Drush commands to prevent any regressions.
Besides my apology, I owe you a beer.
Comment #30
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #31
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedFixing drush webform-libraries-download.
Comment #32
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #33
GrimreaperHello,
I have tested the "drush webform:composer:update" command on the last commit of the branch 2916800-drush-9-v2 and I have the following error:
Also about the generated files for Drush 8 and Drush 9 commands, maybe adding a "// @codingStandardsIgnoreStart" at the beginning of the files would be good to avoid code sniffer warnings.
Comment #36
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@Grimreaper Thanks for the review and suggestions.
Here is a new patch. I also updated the branch.
Comment #37
Grimreaper@jrockowitz, thanks.
I have tested the last version on the branch and the command "drush webform:composer:update" now works ok.
Comment #38
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@Grimreaper Are all the existing webform drush commands working as expected via Drush9.
Comment #39
GrimreaperHello,
@jrockowitz, I have tested all the commands in docs/DRUSH-COMMANDS.md for Drush 9.
Everything is ok except:
Comment #40
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedYep both those commands are working as expected.
Comment #41
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI forgot to port the
drush webform_scheduled_email_cron
command.I tested it and I don't expect there to be a lot of people using it.
Comment #43
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI committed that patch and we should make additional improvements as needed.
Comment #44
GrimreaperGreat \o/ !
Thanks @jrockowitz and @NickWilde.
Comment #45
dimmech CreditAttribution: dimmech commentedI'm getting the following error when trying to download the libraries.
Comment #46
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedWhat version of Drush do you have installed?
drush --version
Comment #47
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI figure out the issue is 9.0.0-rc2. It appears that drush 9.x is going to be moving target for a little while.
The attached patch fixes the missing legacy functions and removes a temporary workaround for 9.0.0-rc1.
Comment #49
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI committed the patch. Please download the latest dev release to review.
Comment #50
dimmech CreditAttribution: dimmech commentedThe commands are working and now I'm recieving the following php error.
[warning] rename(): The first argument to copy() function cannot be a directory WebformCliService.php:701
It appears to be related to this php bug which descibes the following workaround.
exec("mv ".escapeshellarg($strOldPath)." ".escapeshellarg($strNewPath));
It was also subject of a Drupal issue here which @jpstacey resolved. The conditions are the same for me as described there, my /tmp directory is on a different volume then my /var/www directory.
Comment #51
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedLet's use core's file_unmanaged_move() function instead.
I am going to just commit the attached patch. Please download the latest dev release to review.
Comment #53
dimmech CreditAttribution: dimmech commentedWith the current patch i had to make sure that
allow_url_include = On
was set in php.ini otherwise I was getting:After changing php.ini and restarting apache, I now get the following error. I can verifiy the files are downloaded and extracted to this point.
Comment #54
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@dimmech I am unable to replicate the error. Still, I think there some room for improvements.
The attached is a patch uses native Drush 9 functions with the
mv
command as a backup. Does this help?What OS and PHP version are you using?
Does the /libraries directory exist?
Did you check the directories file permissions?
Comment #55
dimmech CreditAttribution: dimmech commentedUsing Ubuntu 16.04 w/ PHP 7.0, /libraries exsist - yes, file permissions - yes.
This patch worked, all library files are there, nice work! Looks like the cross-volume php bug will still error on the mv function but I'm sure you'll decide how to handle that.
This was the output:
Thanks
Comment #56
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedFor now it feels safer to not use the 'mv' command since I can't replicate the error/issue.
Attached is the same patch without the 'mv' command.
Comment #58
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI committed the last patch.
Comment #61
devil2005 CreditAttribution: devil2005 commentedHi, i reopen because i have this error with drush 9
Can you help me please ?
thanks
Comment #62
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedDid you clear drupal's cache?
Comment #63
devil2005 CreditAttribution: devil2005 commentedYes :(
Comment #64
devil2005 CreditAttribution: devil2005 commentedIn fact... "drush cr" is ok, but not "drush status", "drush entup" broken too
Comment #65
devil2005 CreditAttribution: devil2005 commentedA fully update with composer and dependencies to RC4 solved the problem.
Thanks ;)