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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fgm created an issue. See original summary.

fgm’s picture

fgm’s picture

Status: Active » Needs review
FileSize
21.92 KB

In patch format for review here.

fgm’s picture

Issue tags: +Drush-9
Grimreaper’s picture

Hello,

I am trying to apply your patch, but the commands are not detected.

My project structure is as follow:
- drush/commands/drush_language
- src/core, etc.
- composer.json
- bin (from composer)
- vendor

I tried creating a drush.yml config file into the drush folder at the root of my project, the drush config file is detected by drush when I run drush status.

I tried putting in the drush.yml:

drush:
  paths:
    # Specify folders to search for Drush command files.  These locations
    # are always merged with include paths defined on the command line or
    # in other configuration files.  On the command line, paths may be separated
    # by a colon (:) on Unix-based systems or a semi-colon (;) on Windows,
    # or multiple --include options may be provided. Note that the locations shown
    # in the example below were searched by default in Drush 8 and earlier.
    include:
#      - './commands'
#      - './commands/drush_language'
      - 'ABSOLUTE_PATH_TO_PROJECT/drush/commands'
      - 'ABSOLUTE_PATH_TO_PROJECT/drush/commands/drush_language'

After clearing caches each time, I can't see the command when running Drush.

Does drush_language needs to be in a specific folder?

Thanks for any help.

Grimreaper’s picture

Sorry, I didn't take attention to the new README.md file...

Grimreaper’s picture

Assigned: Unassigned » Grimreaper
Status: Needs review » Needs work

Ok. I got error on PHP 5.6 environment I will upload an updated patch.

Grimreaper’s picture

Assigned: Grimreaper » Unassigned
Status: Needs work » Needs review
FileSize
22.69 KB
2.42 KB

Here is the updated patch and the interdiff.

Thanks for the review.

fgm’s picture

I would rather drop PHP 5.6 than drop the type hints, wouldn't you too ? (and add a php: 7.0 in the .info.yml file)

Otherwise:

+++ b/src/Commands/DrushLanguageCommands.php
@@ -338,8 +339,8 @@ class DrushLanguageCommands extends DrushCommands {
+        ? ['customized' => 1, 'not_customized' => 1]

That was my original version, but drupalcs complains with that indent, and doesn't complain when the ?: are in position 6 instead of 8.

Grimreaper’s picture

Hello,

As I have projects at work and personal (Drupalfr site) that are on PHP 5.6, I would prefer the code to support PHP 5.6. Also Drupal 8 Core is compatible with PHP 5.6.

Yes, I would prefer having all the Drupal projects on Earth on PHP 7 but I can't control that :).

About the indentation, sorry I didn't particularly mean to change that, just changes from the IDE when copy pasting.

fgm’s picture

Otherwise, it's good for me, but I can't RTBC it since it wrote too much of it.

fgm’s picture

Just noticed this warning on one site when using it, although it actually works in the end:


vendor/bin/drush language:import:translations fr ../import/translations/explicit/ctools-8.x-3.0-beta1.fr.po
 [warning] Invalid argument supplied for foreach() NestedArray.php:327
 [warning] Invalid argument supplied for foreach() NestedArray.php:327
 [ok] Traductions importées.
 [ok] Mise à jour des traductions de JavaScript et de la configuration par défaut.
 [ok] Mise à jour de la configuration par défaut (0%).
 [ok] Mise à jour de la configuration par défaut (0%).
 [ok] Mise à jour de la configuration par défaut (0%).
 [ok] Mise à jour de la configuration par défaut (0%).
 [ok] Mise à jour de la configuration par défaut (0%).
 [ok] Mise à jour de la configuration par défaut (0%).
 [ok] Mise à jour de la configuration par défaut (0%).
 [ok] Mise à jour de la configuration par défaut (0%).
 [ok] Mise à jour de la configuration par défaut (0%).
 [ok] Configuration par défaut mise à jour.

Happens with all po files, not just Ctools'.

Was not related, but came from elsewhere in the project.

geek-merlin’s picture

Great you work on this!! No time today for a thorough review, but a quick shot: Did you read this:
http://nuvole.org/blog/2017/oct/13/how-maintain-drush-commands-drush-8-a...

It would save us forking a new version, and i'd love to commit it that way if feasible...

fgm’s picture

Yes, that sounds good, but IMHO this is best left for a followup, as it involves refactoring the code, while this patch mostly doesn't affect the Drush 8 operation: the only changes in the .drush.inc are spelling and comments.

Better keep the patch minimal to have a working version for everyone, and only then refactor if there is still a point in keeping Drush 8, and to also possibly make it easier to support console.

egruel’s picture

Hello,

I test patch #8 it's good for me.

fgm’s picture

@grimreaper food for thought about 5.6 https://www.drupal.org/project/drupal/issues/2842431 it's going to be dropped next year, in 8.6.0 anyway.

Grimreaper’s picture

@fgm: Thank you very much for the link.

geek-merlin’s picture

Great you hacked this together and can use it. As stated in #13 for inclusion this needswork.

geek-merlin’s picture

Status: Needs review » Needs work
geek-merlin’s picture

Title: Convert for Drush 9 » Convert for Drush 8/9/console
fgm’s picture

The current PR head at https://github.com/dawehner/drush_language/pull/18 now includes the latest Drush 9 requirements for a composer.json section.

geek-merlin’s picture

#13 elaborated: As a maintainer, i see the issue that this patch will introduce code duplicated in 2 places which makes any subsequent patch cumbersome and error-prone. Fortunately the config-split guys have solved that problem well and - even better - documented their effort. It's super simple!
So if this patch is reworked that way, we can move it in.

Grimreaper’s picture

Assigned: Unassigned » Grimreaper
Grimreaper’s picture

Here is a patch from the PR https://github.com/dawehner/drush_language/pull/18 last version applied on the drupal.org git repository last dev version.

I will try to create the service and make the factorisation. Hope it will be merged...

Grimreaper’s picture

I will push the commits into https://github.com/FlorentTorregrosa/drush_language.

And will notify when it will be ready.

Grimreaper’s picture

I am still working on that.

But that's interesting to note that in D8, languages does not have "status" anymore (and no more "languages" database table). But the module still has disable and enable methods. I think its has not been used/tested.

I will remove its.

Grimreaper’s picture

Still working on this. I am currently testing.

As the default site language is in the simple config "system.site". I think the default language command also didn't work.

Grimreaper’s picture

Manual tests ok for Drush 9.

For Drush 8: "No hook functions were found for language-default." => no one use the default language command.

Grimreaper’s picture

Assigned: Grimreaper » Unassigned
Status: Needs work » Needs review
FileSize
155.24 KB

Manual tests ok for me on Drush 9 and Drush 8.

Please see https://github.com/FlorentTorregrosa/drush_language for the changes.

It would be nice to preserve the different commits. Sorry I have not do that for @fgm works. But if you want I can prepare a branch with the detail of @fgm commits and mine applied on top of that.

Thanks for the review.

And hoping it will be merged before Drush 8 command will move again!!!

geek-merlin’s picture

Status: Needs review » Needs work

Bonjour Florent,

great that you have been working on this. And great you're providing a git multipatchfile, which makes this monster reviewable.
I did a first review, and everything looks thorough. Also i noticed you removed some weirdesses from different origins.
And obsoleted commands: good catch.

> For Drush 8: "No hook functions were found for language-default." => no one use the default language command.
Interesting find.

I'd say let's go all the way and add the console wrapper. So setting needswork.
* isAbsolutePath() is for free, just require webmozart/path-util in our composer.json (we must do this anyway to not rely on other project's implementation details) and change the condition slightly
* The batch should work too as console commands run in booted drupal. (or did you test?)

Grimreaper’s picture

Guten Tag Axel :),

Thanks for your review!

  • webmozart/path-util: Done (new patch and new commit on my Github repository). Good idea! Sometimes I forget the possibilites to use Composer. So simple. Now, that's one less blocker for the next point.
  • Drupal console: I thought about it, but then (as in https://github.com/FlorentTorregrosa/drush_language/commit/1423cc442188a...) I thought that this project name is drush_language and not cli_language or something like that. Maybe it should be renamed.
    About the drush batch process, I don't currently now how to make it with Drupal console, so it needs work. I will ping the Drupal console team for a little help and opinion if they are interested with those commands.
Grimreaper’s picture

Ping in the Drupal console community done: https://gitter.im/hechoendrupal/DrupalConsole?at=5a895380a2194eb80d7be4a6

I have just looked at the current Drupal console commands, and there is already a "locale:language:add" and the default language command can be done with a command to change the config and a cache clear. (For Drush, it can also be done that way)

So the only commands interesting for Drupal console would be the import and export of translations.

Grimreaper’s picture

Priority: Normal » Critical

Hello,

@axel.rutz: no response from the Drupal console community in a week. Do you want to wait more?

Also increasing the priority because if other issues lands in Drush language it will make the work done here unusable or needing to adjust again.

I think we can merge the work done here now without closing the issue for Drupal console support if needed. To avoid patches on other issues to cancel the work done here or in the opposite way to prevent other people working on other issues.

I have just saw the other issues and people are also fixing what will be fixed here (#2873380: No hook functions were found for language-default, #2873379: No hook functions were found for language-enable).

geek-merlin’s picture

Yeah, in fact you addressed 1), and i guess 2) should just work. And if not, we'll do a followup.

Committed, merged and release a RC1!

😍 THanks a lot! 😍

geek-merlin’s picture

Status: Needs work » Fixed
Grimreaper’s picture

Thanks for the commits.

\o/

Grimreaper’s picture

Deleting my mirror on Github as the commits have been merged and this issue is fixed.

fgm’s picture

I archived mine, and suggest you do the same if you haven't already deleted yours, to avoid breaking the sites who could depend on yours the very week 8.5.0 got released.

Would be nice if @daniel wehner did the same for his own.

Grimreaper’s picture

@fgm: oups, already deleted my repository. I had put in the description that my repository was only there the time this issue is resolved. As I don't use regularly the "archive" feature of Github I didn't think about this option. Sorry, you are right, I could have broken websites... My bad.

Status: Fixed » Closed (fixed)

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