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.

CommentFileSizeAuthor
#5 patch_2839643.diff1.91 KBlpsolit
#3 patch_2839643.diff701 byteslpsolit

Comments

Boobaa created an issue. See original summary.

berdir’s picture

The 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.

lpsolit’s picture

Assigned: Unassigned » lpsolit
Status: Active » Needs review
StatusFileSize
new701 bytes
berdir’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Can you maybe extend a test to cover this? change the weight and then edit and save and verify that the weight is unchanged.

lpsolit’s picture

Status: Needs work » Needs review
StatusFileSize
new1.91 KB

Test added to PathautoUiTest.

boobaa’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, 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.

  • Berdir committed 5bdbdc5 on 8.x-1.x authored by LpSolit
    Issue #2839643 by LpSolit: Editing a pattern changes its weight
    
berdir’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs tests

Yeah, works for me, thanks.

Status: Fixed » Closed (fixed)

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