Problem/Motivation

The following scenario is currently not possible:

- Install Drupal 8.7.x + pathauto 1.6
- Code update to Drupal 8.8.x and pathauto 1.7
- Run drush updb

Error:

[error]  TypeError: Argument 2 passed to Drupal\pathauto\AliasStorageHelper::__construct() must be an instance of Drupal\path_alias\AliasRepositoryInterface, instance of Drupal\Core\Path\AliasRepository given, called in drupal/core/lib/Drupal/Component/DependencyInjection/Container.php on line 289 in Drupal\pathauto\AliasStorageHelper->__construct() (line 79 of drupal/modules/contrib/pathauto/src/AliasStorageHelper.php) #0 drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(289): Drupal\pathauto\AliasStorageHelper->__construct(Object(Drupal\Core\Config\ConfigFactory), Object(Drupal\Core\Path\AliasRepository), Object(Drupal\Core\Database\Driver\mysql\Connection), Object(Drupal\pathauto\VerboseMessenger), Object(Drupal\Core\StringTranslation\TranslationManager), Object(Drupal\Core\Entity\EntityTypeManager))

I think the problem is that path_alias is not enabled at that moment and so the interface Drupal\path_alias\AliasRepositoryInterface is not autoloaded.

Proposed resolution

Figure out a way to make this possible.

CommentFileSizeAuthor
#3 3131286-3.patch776 byteschr.fritsch

Comments

chr.fritsch created an issue. See original summary.

berdir’s picture

Strange, I would expect it to work, definitely did that on projects. The problem in your case might be that something instantiates that service before the path_alias module gets enabled?

You could try to extend \Drupal\pathauto\PathautoServiceProvider and check if the module is enabled based on the available definitions?

chr.fritsch’s picture

Status: Active » Needs review
StatusFileSize
new776 bytes

Thanks for the hint with the service provider.

I figured out that drush is causing the problems. During the container build of the pathauto drush commands, it tries to resolve the 'pathauto.alias_storage_helper' service, which is not possible because the path_alias module is not enabled.

So, removing the service definition for the pathauto drush commands resolved my problem.

andrewtur’s picture

Hi I had the same error the patch help tank you.

kris77’s picture

Thank you so much for patch @chr.fritsch.

Patch in #3 work for me with last release of Pathauto (8.x-1.7) and Drupal 8.8.5.

berdir’s picture

8.8.5? This should only be a problem when updating from 8.7 to 8.8, if you have this on an updated 8.8 site then your site is broken :)

b_sharpe’s picture

Same, 8.7.11 -> 8.8.5. Patch resolved the issue.

Anonymous’s picture

Live saver, thank you

weseze’s picture

Same issue when updating, patch resolved the issue.

alexpott’s picture

This is a super interesting issue caused by our multiple major version compatibility. And it’s likely to happen more and more as modules get ported. Currently if you are on Drupal 8.7 and you have pathauto installed - if you follow instructions and update both core and pathauto and at the same time. Things will break. The latest version of pathauto (1.7.x) is not compatible with Drupal 8.7 and prior to the update running, early Drush code breaks (this could also happen with core - we’re just lucky in this case it hasn’t). You need to make the update with version 1.6.x which is 8.8.x compatible but uses deprecated code. 1.7.x has removed deprecated code usage and this is why it is breaking.

berdir’s picture

Note to everyone running into this. An easier workaround than using the patch is updating to 8.8 with pathauto 1.6 and then updating to 1.7 later. There are no important fixes in 1.7. I'll commit this soon.

weseze’s picture

Should we not keep all BC code that was removed in 1.7 and just mark it as deprecated. Then remove it in the Drupal 9 version?
Or am I seeing things a bit oversimplified here?

kris77’s picture

Hi @Berdir, i had drupal 8.8.5 and pathauto 8.x.1.6 and everything worked fine.

After upgrading pathauto to 8.x.1.7 the error came out.

My error was specific to "\Drupal\pathauto\PathautoServiceProvider"

berdir’s picture

> Hi @Berdir, i had drupal 8.8.5 and pathauto 8.x.1.6 and everything worked fine.

Is the path_alias module enabled on your site? If it's not then it is far from working fine :)

> My error was specific to "\Drupal\pathauto\PathautoServiceProvider"

I'm not sure what that means, what error exactly?

kris77’s picture

@Berdir, I don't see the path_alias module in my list...

I have always installed the modules with composer and in the system report I have no errors.

berdir’s picture

It's a new, required core module since 8.8, so it's not in composer.json.

The patch only fixes a very specific issue at the beginning of an 8.7 => 8.8 update, so again, what exactly is the error that you have?

kris77’s picture

You're right @Berdir.

I got the wrong website.
I updated the pathauto module on two websites, but one was still with Drupal 8.7.

I'm sorry for the mistake.

  • Berdir committed 2b21801 on 8.x-1.x authored by chr.fritsch
    Issue #3131286 by chr.fritsch: Updating core 8.7 -> 8.8 with pathauto...
berdir’s picture

Status: Needs review » Fixed

Ha, no worries, I'm glad we sorted it out and there aren't any other weirder issues hiding here. The fix isn't pretty, but should be good enough to get people to 8.8, which is all that matters.

Committed.

berdir’s picture

This patch might accidentally also fix issues like the one reported here: #3131490: WSOD after every operation warnings related to pathauto, because the apc classloader still thinks that the class should exist and then tries to load it. So if this patch helped you on an already updated D8 site, that might be the problem. As written there, restart your webserver.

corn696’s picture

I was able to update from Core 8.7 to Core 8.8.5 together with Pathauto from 1.3 to 1.8

But I still get this error with the Bibliography & Citation module (dev).

I had to update the Bibliography & Citation module separately after updating to Core 8.8.5 and Pathauto 1.8

Status: Fixed » Closed (fixed)

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

john.oltman’s picture

Upgrading to Drupal core 8.9.18 and pathauto 1.8 and I had to enable path_alias explicitly before the updb would work.