Comments

xurizaemon created an issue. See original summary.

xurizaemon’s picture

Status: Active » Needs review
StatusFileSize
new1.82 KB
xurizaemon’s picture

Updated to account for recent changes - can't see related issue but it related to batches and was committed in dde78ba3523e9548f6789c453e6ab2456def11ee

xurizaemon’s picture

andrewmacpherson’s picture

Status: Needs review » Needs work

Review of patch #3:

  1. There are 3 instances of drush_log() in the module. Patch #3 has caught all the instances. Good.
  2. However, it looks like we should replace it with Drush::logger(), rather than \Drupal::logger(). See pull request #3810 Replace drush_set_error() and drush_log() via Drush::logger() in the Drush repo for examples.
  3. The module also uses drush_set_error(), so we should update that too.

I'll post an updated patch soon.

andrewmacpherson’s picture

Patch #3 also removed a call to dt(). This seems unnecessary, because dt() is still present in Drush 10.1 and isn't marked as deprecated.

andrewmacpherson’s picture

Title: Replace deprecated drush_log with Drupal logger » Replace drush_log and drush_set_error with Drupal logger
Status: Needs work » Needs review
StatusFileSize
new2.89 KB
new2.47 KB

This patch addresses #5 and #6...

  1. Uses Drush::logger() instead of Drupal::logger().
  2. Replaces drush_set_error() with Drush::logger()->error(). This is a more urgent issue; drush_set_error() has been removed completely in Drush 10, while the deprecated drush_log() is still available.
  3. Restores a dt() removed by patch #3.
  4. Adds a version conflict to the composer file. Drupal core 8.8.1 conflicts with Drush < 8.1.10. However Drush::logger() was introduced in Drush 8.1.18 - this is higher than Drupal core's current requirement, so I added a conflict key to Migrate Manifest's composer file.

I haven't tested this yet, but I have a personal project which I want to use migrate manifest with so I'll test this very soon. (I arrived here because I ran into the problem with drush_set_error() not being present in Drush 10.)

andrewmacpherson’s picture

Title: Replace drush_log and drush_set_error with Drupal logger » Replace drush_log and drush_set_error with Drush::logger
andrewmacpherson’s picture

StatusFileSize
new3.67 KB
new1.27 KB

It also needed a bunch of use statements.

andrewmacpherson’s picture

Title: Replace drush_log and drush_set_error with Drush::logger » Compatibility with Drush >= 9

I've encountered another snag. This issue is probably better scoped as compatibility with Drush > 8, than with use of specific logger functions.

MigrateManifestCommands makes use of drush_invoke_process(), which has been removed in Drush 10 and replaced with Drush::drush()->mustRun() et. al..

We could replace the call to drush_invoke_process() in MigrateManifestCommands, while leaving it in place in migrate_manifest.drush.inc for Drush 8 use.

The snag is that Drush::drush() isn't available until 9.5, and drush_invoke_process() isn't available at all in Drush 10. So how can we make this compatible with Drush 9 and Drush 10?

I'm guessing we can check MigrateManifestCommands to check whether we have Drush 9 or 10, and either call drush_invoke_process() or Drush::drush() as appropriate. It might be as easy as checking function_exists(), or perhaps there's a Drush-specific approach to this.

I'll ask for opinions in the Drush channel on Drupal Slack.

andrewmacpherson’s picture

Title: Compatibility with Drush >= 9 » Upgrade Migrate Manifest to Drush 10
Issue summary: View changes
StatusFileSize
new3.93 KB
new6.54 KB

I chatted with (Drush maintainer) about this on Slack.

Rather than try to support Drush versions 9 and 10, and try to detect which API functions are needed, it's simpler to require Drush >= 9.7. This was the last minor version prior to Drush 10, and the difference is that Drush 10 just removed the deprecated stuff (I think).

This patch:

  • Replaces drush_invoke_process() with the newer Drush::drush() approach in MigrateManifestCommands
  • Bumps the required Drush version to <9.6
  • Removes the old-style migrate_manifest.drush.inc file, so Drush 8 is no longer supported.

The last point (dropping support for Drush 8) is something the module maintainer needs to decide upon though.

benjifisher’s picture

I am just trying this out for the first time today, so maybe I am doing something wrong, but when I try

drush mm ../migrate-manifest.yml --legacy-db-key=migrate

I get the error

Error: Call to undefined function Drupal\migrate_manifest\drush_get_option() in /app/docroot/modules/contrib/migrate_manifest/src/MigrateManifest.php on line 198

Is drush_get_option() one of the deprecaetd and/or removed functions?

I am using drush 10.2.2.

benjifisher’s picture

Another issue: when I add the -v (verbose) flag, I see a lot of

[info] Running @id

That looks like a parameter that did not get replaced.

benjifisher’s picture

Another thing I get when running drush -v mm:

[info] migrate_manifest should have an extra.drush.services section in its composer.json. See http://docs.drush.org/en/master/commands/#specifying-the-services-file.

I am setting the status to NW for this and the comments I made in #12 and #13.

ravimane23’s picture

Assigned: Unassigned » ravimane23
Status: Needs review » Needs work
Issue tags: +Drupal 9 compatibility, +Drupal 9

Some errors still exists while making compatible with Drupal 9

drupal-check -d modules/contrib/migrate_manifest
8/8 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

------ ----------------------------------------------------------------
Line src/Commands/MigrateManifestCommands.php
------ ----------------------------------------------------------------
48 Call to deprecated method logger() of class Drush\Drush:
Use injected logger instead.
51 Call to deprecated method aliasManager() of class Drush\Drush:
Use injected alias manager instead. @see Drush::drush()
------ ----------------------------------------------------------------

------ ----------------------------------------------------------
Line src/DrushLogMigrateMessage.php
------ ----------------------------------------------------------
19 Call to deprecated method logger() of class Drush\Drush:
Use injected logger instead.
------ ----------------------------------------------------------

------ ----------------------------------------------------------
Line src/MigrateManifest.php
------ ----------------------------------------------------------
126 Call to deprecated method logger() of class Drush\Drush:
Use injected logger instead.
185 Call to deprecated method logger() of class Drush\Drush:
Use injected logger instead.
------ ----------------------------------------------------------

[ERROR] Found 5 errors

ravimane23’s picture

Assigned: ravimane23 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new7.18 KB
new2.65 KB

Added generated patch using "drupal-check" to make it compatible with Drupal 9.

neclimdul’s picture

Status: Needs review » Fixed

Thanks everyone.

  1.  +    Drush::logger()
     +      ->$type($message);
    ---
     +    \Drupal::logger($message, $type);
    

    I don't think this is what the intention was for the deprecation. Also the signature is wrong, core's logger method only takes one argument and returns a service. Also Drush still uses this method pretty heavily so I don't know how big a deal it is. Not sure how I want to fix this yet but I'll fix it on commit shortly.

  • neclimdul committed 121440c on 8.x-1.x authored by ravimane23
    Issue #2977966 by andrewmacpherson, xurizaemon, ravimane23: Upgrade...
benjifisher’s picture

Cross-post: I had written the following.


@ravimane23:

Thanks for working on Drupal 9 compatibility. But being compatible with Drupal 9 is different from being compatible with Drush 10.

Please see Creating an interdiff for the recommended ways to create an interdiff.

+++ b/src/Commands/MigrateManifestCommands.php
@@ -44,10 +49,11 @@ class MigrateManifestCommands extends DrushCommands {
       $manifest_runner->import($manifest);
     }
     catch (\Exception $e) {
-      drush_set_error('MIGRATE_ERROR', $e->getMessage());
+      \Drupal::logger($e->getMessage(), 'error');

Using Drupal::logger() goes against the recommendation in #5. If you think that comment is wrong, then please explain why.

I do not think Drupal::logger() accepts two arguments. Perhaps you mean \Drupal::logger('migrate_manifest')->error($e->getMessage()).

In #14, I wrote

I am setting the status to NW for this and the comments I made in #12 and #13.

but it looks as though I left the status at NR. Let me do that for real now.


I guess I will leave the status unchanged and open a follow-up for #12 and #13. For reference, can you post the patch that was actually committed?

neclimdul’s picture

StatusFileSize
new6.65 KB

Sorry about the cross post, that's always frustrating. Glad we're in agreement about the logger changes. Part of this is definitely my fault because in the time since this patch started to now Drush has push things toward Drush::logger() and then also deprecated it and that messes things up. Also harsh, 5 months is some fast moving APIs. :(

I think #12 might have been addressed. I can't find any references to drush_get_option
For #13, I haven't tested but the code _looks_ correct. I don't know why Drush's logger wasn't replacing before like its suppose to but Ravi's patch added a dt() around it and I left that in. Please test and let me know if that fixes it or if we need a follow up..

I meant to follow up with an interdiff, esp since the changes ended up being more involved then expected but I got pulled into a meeting and distracted. Obviously you can see the full commit in the linked commit message and the changes from #16 are in this interdiff. Summary, everything gets a logger in the constructor and it uses DrushCommand's logger trait to get the logger(and pass it to the helper classes). I think the biggest change is the migrate message class which has some BC code in the constructor just to be safe and it got a quick test to make sure everything is translated reasonably to Drush's PSR logger. Mostly because 'status' is not a valid PSR log level.

neclimdul’s picture

Side note, I have mixed feelings about the drush 8 support going away because I'm very aware migrations end up with weird requirements. I couldn't come up for a case where it really made sense though. If someone gets here because they do need it, I'm not appose to adding it back just open an issue and give me a reason :)

benjifisher’s picture

I should be able to test soon. For now, just to save a few clicks,

neclimdul’s picture

Note, you'll have to check this in 8.x. Drupal 9 is currently blocked by this. https://www.drupal.org/project/drupal/issues/3154398#comment-13715800

Status: Fixed » Closed (fixed)

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