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.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3131286-3.patch | 776 bytes | chr.fritsch |
Comments
Comment #2
berdirStrange, 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?
Comment #3
chr.fritschThanks 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.
Comment #4
andrewtur commentedHi I had the same error the patch help tank you.
Comment #5
kris77 commentedThank 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.
Comment #6
berdir8.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 :)
Comment #7
b_sharpe commentedSame, 8.7.11 -> 8.8.5. Patch resolved the issue.
Comment #8
Anonymous (not verified) commentedLive saver, thank you
Comment #9
weseze commentedSame issue when updating, patch resolved the issue.
Comment #10
alexpottThis 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.
Comment #11
berdirNote 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.
Comment #12
weseze commentedShould 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?
Comment #13
kris77 commentedHi @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"
Comment #14
berdir> 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?
Comment #15
kris77 commented@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.
Comment #16
berdirIt'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?
Comment #17
kris77 commentedYou'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.
Comment #19
berdirHa, 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.
Comment #20
berdirThis 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.
Comment #21
corn696I 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
Comment #23
john.oltman commentedUpgrading to Drupal core 8.9.18 and pathauto 1.8 and I had to enable path_alias explicitly before the updb would work.