Editing a pathauto pattern changes its weight – in my case, to -5. This is particularly painful when there is a fallback pattern with a weight in between the original and the changed value.
Here's an example. Let's start with these patterns:
- Node.Audio with weight -10,
- Node.Image with weight -9,
- Node.Story with weight -8,
- Node.Book with weight -7,
- Node with weight -6,
- Taxonomy.Tags with weight -5,
- Taxonomy with weight -4.
Editing Node.Book changes its weight to -5, so it will not apply any longer, because Node kicks in sooner.
Expected behavior: the pattern's weight does not change when editing it.
Comments
Comment #2
berdirThe reason for this is in \Drupal\pathauto\Form\PatternEditForm::buildEntity(), it is an attempt to provide a better out of the box experience but agreed that it is a problem when editing existing ones.
Should be relatively easy to wrap the weight call and only do if ($entity->isNew()), with a comment. Patches welcome.
Comment #3
lpsolit commentedComment #4
berdirCan you maybe extend a test to cover this? change the weight and then edit and save and verify that the weight is unchanged.
Comment #5
lpsolit commentedTest added to PathautoUiTest.
Comment #6
boobaaThanks, it solves the problem and the test looks good, too.
Next time please name your patch file like pathauto-pattern_weight-2839643-5.patch (per recommendations). This makes people's life easier when they have to deal with a number of patches for different modules on their sites.
Comment #8
berdirYeah, works for me, thanks.