Closed (fixed)
Project:
Pathauto
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
16 Feb 2016 at 14:16 UTC
Updated:
9 Mar 2016 at 19:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
juampynr commented@Berdir, I am not sure at how to tackle this one. It seems that we would have to add a bunch of if statements at PatternEditForm and PathautoTestHelperTrait. It can get very complex to read. Do you have any tips?
Comment #3
juampynr commentedInteresting, the first version of the patch looks simpler than what I thought. I will now work in tests and the update path while tests run here.
Comment #4
juampynr commentedHere is another patch with a database update. Should we add any tests @berdir? I am not sure that we need them.
Comment #5
berdirYeah, that doesn't look too complicated. My suggestion in IRC was to use a helper function, but considering that this is so easy and only a single place actually needs to be dynamic, I'd say this is fine.
However, note that you missed one spot, a helper method in the tests, where we create entity bundle conditions dynamically.
This is not something that we've done so far, but note that it is problematic to use the entity API in update functions.
Imagine we'd add a new feature that runs in PathautoPattern::postSave() and it would require different or new configuration that we, in this update, don't have yet.
Then someone might update directly from alpha1 to beta3 or whatever and will run this update with the latest code base.
The way to avoid this is to use the config API directly and work on the raw config structure. Or, alternatively, you could also write a post update function, those are always run after all other update functions were run and after caches were cleared. There it's allowed to use entity API.
That said, we still are in alpha, and I'd still say our upgrade path support is on a best effort basis and that we'd simply not support updating such an old version directly to whatever future version would introduce that change.
But it's something to consider in future update functions.
"swap it to the node_type plugin". I'd say.
I think ternary conditions like this are usually written on a single line.
Comment #6
juampynr commentedThanks for the feedback @berdir. Here is a new patch with your suggestions.
Comment #8
berdirNice work. Tested the upgrade path manually, all looks good.