Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Path aliases will be converted to entities in core #2336597: Convert path aliases to full featured entities, we need to update Pathauto in order to make it work with Drupal 8.8.0.
Proposed resolution
Add a new implementation of the pathauto.alias_storage_helper
service that works with the path_alias
implementation from Drupal 8.8, and keep the existing one for a while by registering it dinamically if the core version is < 8.8.
Remaining tasks
Review.
User interface changes
Nope.
API changes
Nope.
Data model changes
Nope.
Comment | File | Size | Author |
---|---|---|---|
#31 | interdiff-16-31.txt | 15.19 KB | amateescu |
#31 | 3012050-31.patch | 27.12 KB | amateescu |
#21 | interdiff-16-21.patch | 19.99 KB | pookmish |
#21 | pathauto-3012050-21.patch | 28.32 KB | pookmish |
#16 | 3012050-16.patch | 22.39 KB | amateescu |
Comments
Comment #2
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedSome initial work on this. A few tests pass locally but there are still a few that need to be investigated and fixed.
Comment #3
amateescu CreditAttribution: amateescu for Pfizer, Inc. commented@Berdir told me that we can include a
drupalci.yml
file in here so we can run the module's tests with the core patch applied. Let's try that :)Comment #5
jibranReroll with the new patch.
Comment #7
jibranThis time with a new patch.
Comment #9
jibranThis should pass more tests.
I'm not sure about this change.
Comment #11
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedNew patch based on #2336597-142: Convert path aliases to full featured entities. Should be all shiny and green :)
Comment #12
BerdirThis stuff is all a bit scary and I'm wondering how much of it is really still necessary.
Wondering if we should rethink that save() API. I don't really care about API stability of this, we're breaking it anyway by expecting a path entity object now. See below.
also open to removing methods that are now official supported by the API.
Yes, as I suspected...
Wouldn't it become much easier if we'd just decide here if we should update or duplicate? Either you update $existing_alias and save, or create a new and save.
these batch queries are ugly, but there isn't really a way to abstract with these custom conditions, and looping over all would result in massively slowing it down, especially when updating e.g. just term aliases and you have 1M node aliases.
Comment #13
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedThanks for the review!
1. Now that you mention it, we can clean this up quite a bit :)
2. Glad to head that, removed two methods which are not needed anymore:
loadBySource()
andcountAll()
.3. I think it's equally easy if we keep that decision in the save() method, but in order to do that we need to pass all the information about the new alias as separate arguments rather than a pre-constructed path alias object.
4. Agreed that the current ugliness is still very much needed..
Comment #14
jibranNice to see that we can improve the code. Let's update IS with API changes and let's start a draft change record as well.
Comment #15
Berdir1. Yeah, that's a good idea.
What I was wondering about is whether we could make a patch that works with both 8.7 and 8.8, that would mean we would have to add these methods back, and we could possibly even have two different implementations for 8.7 and 8.8 that we could register dynamically. That should work quite well. The generator and some other parts might be uglier?
While more work, I think that might also be beneficial for the being able to get the core issue in and we could commit this early, making testing and updating easier?
Comment #16
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedI was thinking about that too in the last few days, and now that I got to know the codebase pretty well, it's not even that hard to do :)
Edit: the only difference in the two patches is that the first one contains the druaplci.yml file which applies the conversion patch to core.
Comment #18
jibran#2336597: Convert path aliases to full featured entities is in so what is the plan here? Are we going to create a new 2.x branch?
Comment #19
botanic_spark CreditAttribution: botanic_spark at FFW, Develomon commentedPatches are not applying to latest dev version.
Comment #20
botanic_spark CreditAttribution: botanic_spark at FFW, Develomon commentedComment #21
pookmish CreditAttribution: pookmish commentedThe patch in #16 was able to apply for me. However it causes breaking issues. The patch references an interface that doesn't exist and methods on the alias storage that don't exist. Those methods however exist in the path.alias_storage service. Adding that service and changing the method calls appears to help out. I noticed these errors when trying to save after editing an existing node.
I've included the interdiff but it doesn't appear accurate to me. Forgive me if there's a better way to make the interdiff.
Comment #22
botanic_spark CreditAttribution: botanic_spark at FFW, Develomon commentedPatch #21 applies nicely and it looks like it's working as expected.
Comment #23
botanic_spark CreditAttribution: botanic_spark at FFW, Develomon commentedComment #24
BerdirThanks for working on this, note that we're currently explicitly holding out until 8.8.0-alpha1 is released next week, there are still some more things going on that will hopefully get in until then.
It's too early to test 8.8 + pathauto right now, give us another week to finalize this. I can guarantee that I will release a compatible version in time, don't know yet if that will be a new 2.x branch or not, I'd rather not and would prefer to just mark our own storage helper as internal, I hope people didn't rely on that too much.
Comment #25
super_romeo CreditAttribution: super_romeo commentedAfter applying patch #21:
Comment #26
super_romeo CreditAttribution: super_romeo commentedCR fixed this. Sorry.
Comment #27
alison#21 fixed the problem I had with core 8.8.x where I couldn't delete user accounts, or bulk update path aliases (I got PHP errors / database exceptions complaining that
Table 'mydbname.url_alias' doesn't exist
-- happy to offer more info if it's useful, but it seems like things are good now, as far as I can tell).FWIW, I had some trouble applying the patch via composer -- but I'm not convinced it was a problem with the patch, I may have been in one of those composer twilight zones that happens from time to time -- and eventually it worked, I just had to do some hacky manual updates -- point is, I feel like it was specific to my situation, not the patch, but I'm sharing anyway "just in case" someone else notices it, too, or whatever.
Thanks so much, all!
Comment #28
jibranLocale test is failing for last patch see https://www.drupal.org/pift-ci-job/1439407.
Comment #29
kim.pepper8.8.0-alpha1 is out, so this is un-blocked.
Comment #30
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedWe're still waiting to see if #2233595: Deprecate the custom path alias storage can land before core's next alpha/beta.
Comment #31
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedThis should work fine with Drupal 8.8.0-alpha1. Interdiff is to #16.
Comment #32
BerdirThis seems a bit inconsistent/strange.
We move entity type manager argument to the end and replace it with alias storage? Why not add alias storage to the end?
Also we check entity type manager for optional but not alias storage.
Comment #33
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedBecause the alias storage service still exists in 8.8.0-alpha1, and putting the entity type manager at the end makes it easier to provide a fallback in the
AliasStorageHelper
constructor :)Comment #34
BerdirYeah, I mixed up the patch files there somehow. This looks fine I think, committed.