Drush 9 no longer supports drush 8 commands. Key module commands need to be updated to support drush 9.

Comments

kmoll created an issue. See original summary.

kmoll’s picture

StatusFileSize
new12.56 KB

Here is my initial implementation. Need to test it out, but wanted to push the patch here now.

kmoll’s picture

Status: Active » Needs work
ryan.ryan’s picture

StatusFileSize
new110.01 KB

Not sure if this needs a new issue or not, but probably relevant here. When using the "key-save" command, which seems to work great at first, the key that is saved isn't given a UUID. This of course is a problem when exporting the configuration and importing it on another site.

Example:

drush key-save tmp --key-provider=file --label=Tmp --key-type=encryption --key-type-settings='{"key_size":256}' --key-provider-settings='{"file_location":"../keys/tmp.key","base64_encoded":true}' -y

Resulting key:

A screenshot showing that the exported key lacks UUID.

rlhawk’s picture

Thanks for the info about the null UUID. I've addressed it in #2935263: key-save Drush command does not generate UUID.

rlhawk’s picture

@kmoll - Are you actively working on this? If not, will you unassign yourself? Thanks.

kmoll’s picture

I can make this update, will try to do so tomorrow.

rlhawk’s picture

Terrific, thanks!

kmoll’s picture

StatusFileSize
new13.37 KB

I have updated the key-save method in the commands file. I tested with the example above and it correctly creates the UUID.

kmoll’s picture

Status: Needs work » Needs review
rlhawk’s picture

Status: Needs review » Needs work

Thanks, @kmoll. The key:save command looks good. Are you going to work on the other commands?

kmoll’s picture

@rlhawk, I wasn't ware there were issues with the other commands. The save command seemed to be the only one affected by the UUID issue mentioned above. But I will re-test all other commands and ensure they are working.

kmoll’s picture

I've gone through all the commands, and I need to make a few tweaks:

1. Key-type command output format should be 'table' to keep it consistent.
2. Key-provider returns the same result as Key-type, so I think its key-types, so this has to be updated.
3. key-value command is not working.

Please let me know if you guys see any other issues. I will have an updated patch with these updates shortly.

rlhawk’s picture

Those are the only issues I noticed. Thanks!

kmoll’s picture

I've fixed those issues.

kmoll’s picture

Status: Needs work » Needs review
rlhawk’s picture

2912756-port-drush-15.patch unexpectedly undoes a few recent commits. Once I reverted those, the updated commands looked generally good. Here are some comments:

  • The alias for key:value-get is key-test. It should be key-value.
  • The alias is displayed for key:value-get, but not for any other commands. I can't seen any difference in the @aliases declarations and the aliases all seem to work.
  • Perhaps it's my setup, but I'm randomly getting a thrown exception,
    Symfony\Component\Console\Exception\CommandNotFoundException, with the error There are no commands defined in the "key" namespace. Randomly, like issuing the same command repeatedly sometimes results in the exception and sometimes doesn't.
rlhawk’s picture

Status: Needs review » Needs work
kmoll’s picture

StatusFileSize
new13.69 KB

The key-test was a test value I left in there by accident, this patch fixed that.
I think the alias displays only for that because it is different than the actual command (although the commands have colons in the name). So the function and command is 'value-get', but the alias is key-value. That is the only thing I can think of.
Not sure about that 3rd error. I have not seen that error before.

I think the issue with the commits is that I pulled the latest 8.x-1.x but I didn't rebase my branch when I created that patch. So I made sure I had the latest 8.x-1.x branch, then I rebased my branch, so I think that should fix it. Let me know if it doesn't or there are other issues.

kmoll’s picture

Status: Needs work » Needs review
rlhawk’s picture

StatusFileSize
new13.57 KB
new6 KB

Ah, that makes sense about the aliases. The unpredictable errors did seem to be specific to my installation.

Here's a new patch with a few extra tweaks:

  • Defined drush.services.yml as the Drush services file in composer.json
  • Replaced deprecated _convert_csv_to_array calls with StringUtils::csvToArray
  • Removed overwrite option from key:save and replaced it with a confirmation; removed confirmation when creating a new key with key:save
  • Slightly modified the confirmation text to match other commands' confirmations
rlhawk’s picture

@kmoll - Can you take a look at the latest tweaks that I made and, if they look OK, mark this issue RTBC? Thanks.

kmoll’s picture

@rlhawk Looks good, ran through all commands again. They all worked. I see the confirmation prompt when re-saving a key. I think its good to go now.

kmoll’s picture

Status: Needs review » Reviewed & tested by the community
douggreen’s picture

Status: Reviewed & tested by the community » Needs review

I don't think this is RTBM yet. We need to change the current drush commands (to support Drush 8 and below) to use the service per http://gbyte.co/blog/creating-drush-9-commands-and-porting-legacy-commands. I think this means creating a new service, and calling that service from both the .drush.inc and KeyCommands. I'll work on that change.

rlhawk’s picture

Status: Needs review » Needs work

@douggreen - The commands for both versions of Drush already call the same services provided by Key (e.g., key.repository, plugin.manager.key.key_type). Can you clarify what you mean?

douggreen’s picture

StatusFileSize
new29.42 KB

@rlhawk I thought that we wanted to do something like the attached so that the code only needed to be maintained in one place, and so that we could add Drupal console support too. This doesn't quite work yet. The confirm() code needs to be sorted out. And for Drupal console we'll need to handle dt.

(BTW, I can't test with Drush 9 right now, something in master has a composer conflict, and isn't installing)

rlhawk’s picture

OK, I'll take a look.

rlhawk’s picture

I'd love to get the Drush 9 support committed. What do you think about doing the refactoring work in a separate issue?

kmoll’s picture

I am checking out the new patch now. There is an issue with certain types of things. For instance, in drush 8, there is a drush_set_error, command, where as in drush 9, you just throw an exception and it handles it like and error. If we consolidate to a single service file like that then we are going to run into inconsistencies. I like the idea of having everything in one place, makes it easier to maintain, but I think there maybe some incompatibilities.

That is just one issue I've come across, haven't done a full evaluation of the patch. I am able to run both versions of drush, so I can continue to go through and see if there are any other issues. I am always for iterations as well. IMO I think we could go with the patch we have and handle the refactor in another issue, if there are no objections.

I will continue to look at the patch and see what other updates, if any need to be handled and compile a list, then we can determine if its even worth it to try to refactor to single service for the commands.

douggreen’s picture

Status: Needs work » Reviewed & tested by the community

I haven't found a single other project trying to maintain drush 8 and drush 9 commands with a compatibility layer. I think that the plan is to stop supporting the drush 8 commands, and eventually to remove them.

Let's go with #21. This is the way of the future.

The new command file is auto-generated. I have some critique of it. If we're going to fix anything, it shouldn't be here, but in the auto-generation.

  • rlhawk committed 7a0d4e2 on 8.x-1.x authored by kmoll
    Issue #2912756 by kmoll, rlhawk, douggreen, ryanissamson: Port drush...
rlhawk’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

douggreen’s picture

IIRC, this was missing the new key-format from Drush 8, that now needs to be forward ported to Drush 9.