Problem/Motivation

When module upgraded from 8.x-1.0 to 2.x it's not possible to run drush updb.
Starting from 2.x version this module using "migrate_tools" module as dependency and this module installed in update hook path_redirect_import_update_9001.
But drush updb failed because registration of drush services in cotainer runs before drush updb command and drush service /src/Commands/PathRedirectImportCommands.php extends MigrateToolsCommands class from migrate_tools module which was not installed yet. This is leads to error after running drush updb:
[error] Error: Class "Drupal\migrate_tools\Commands\MigrateToolsCommands" not found in include() (line 27 of /modules/contrib/path_redirect_import/src/Commands/PathRedirectImportCommands.php)

Steps to reproduce

  1. Install module "path_redirect_import" version 8.x-1.0-beta5. Make sure that the module "migrate_tools" is not installed.
  2. Upgrade module "path_redirect_import" to 2.0.5 version
  3. Run drush updb

Result:
[error] Error: Class "Drupal\migrate_tools\Commands\MigrateToolsCommands" not found in include() (line 27 of /modules/contrib/path_redirect_import/src/Commands/PathRedirectImportCommands.php)

Proposed resolution

Disable drush service "path_redirect_import.commands" before module "migrate_tools" not installed.

Remaining tasks

Write a patch

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

qzmenko created an issue. See original summary.

qzmenko’s picture

StatusFileSize
new1010 bytes

Created MR, please review. Also patch attached.

qzmenko’s picture

Status: Active » Needs review
scottsawyer’s picture

Status: Needs review » Reviewed & tested by the community

Brilliant, and it works. Even better.

prabuthe’s picture

I am getting this error

Error: Class "Drupal\migrate_tools\Commands\MigrateToolsCommands" not found in include() (line 25 of C:\Sapient\new\ej-d8-sites\docroot\modules\contrib\path_redirect_import\src\Commands\PathRedirectImportCommands.php).
[30;43;1m[warning][39;49;22m Drush command terminated abnormally.

alina.basarabeanu’s picture

With the patch applied, I get a new error:
The service "drush.command.services" has a dependency on a non-existent service "path_redirect_import.commands".

eugene.brit’s picture

StatusFileSize
new934 bytes
new1.08 KB

Added 'path_redirect_import.redirect_export' service to the #2 patch

alina.basarabeanu’s picture

Patch #8 fixed the drush command error.

plopesc’s picture

StatusFileSize
new1.53 KB

New patch version including some minor changes.

  • plopesc committed 34864f95 on 2.0.x authored by eugene.brit
    Issue #3313386 by qzmenko, eugene.brit, plopesc, Alina Basarabeanu,...
plopesc’s picture

Status: Reviewed & tested by the community » Fixed

Patch committed.

Marking issue as fixed.

Thank you!

Status: Fixed » Closed (fixed)

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

d0t15t’s picture

StatusFileSize
new679 bytes

I'm having this issue again, but the issue is that Drupal\migrate_tools\Commands\MigrateToolsCommands has moved to: Drupal\migrate_tools\Drush\MigrateToolsCommands

alina.basarabeanu’s picture

I tried to use the dev version without the patch but the issue is not resolved.
Error: Class "Drupal\migrate_tools\Commands\MigrateToolsCommands" not found in include() (line 27 of /var/www/html/docroot/modules/contrib/path_redirect_import/src/Commands/PathRedirectImportCommands.php).
Will have to continue using the patch from #8.
Please reopen the issue as is not fixed.

alina.basarabeanu’s picture

Actually, this issue is related to https://www.drupal.org/project/path_redirect_import/issues/3373025
The patch from 3373025 fixed the issue

tmwagner’s picture

I concur with #16. The error described in #15 was corrected for us with the patch from https://www.drupal.org/project/path_redirect_import/issues/3373025

lucasvm’s picture

Patch #11 worked for us, Drupal 10.1.2

rclemings’s picture

@lucasvm: This issue is closed but the issue mentioned in comments #16 and #17 has an identical patch and is RTBC, so it might be better to post any further comments there.

ayush9598 made their first commit to this issue’s fork.

ddavisboxleitner’s picture

Our team also came to this issue looking for help on the error. We were seeing this after upgrading:

Error: Class "Drupal\migrate_tools\Commands\MigrateToolsCommands" not found in include() (line 27 of /var/www/html/docroot/modules/contrib/path_redirect_import/src/Commands/PathRedirectImportCommands.php).

We agree with #16 as well, the patch from https://www.drupal.org/project/path_redirect_import/issues/3373025 updates the path and resolves the error.