Problem/Motivation
The upgrade from 8.x-1.14 to 8.x-1.15 appears to have changed the selection_criteria in the Content Type pattern YAML from an array to a structure. When saving a pattern the criteria are duplicated.
Steps to reproduce
When I edit an old pattern (this doesn't happen with new patterns or patterns updated during the upgrade to 8.x-1.15) and save it without making any changes, the Pathauto form duplicates the Conditions text "Content type is X".
As an example, the configuration YAML for the Course content type pattern changes from ...
selection_criteria:
-
id: 'entity_bundle:node'
negate: false
context_mapping:
node: node
bundles:
course: course
... to ...
selection_criteria:
0:
id: 'entity_bundle:node'
negate: false
context_mapping:
node: node
bundles:
course: course
REDACTED_UUID:
id: 'entity_bundle:node'
negate: false
context_mapping:
node: node
bundles:
course: course
The configuration YML for the Blog content type pattern was updated during the upgrade to 8.x-1.15, and it behaves as expected.
Proposed resolution
The pattern config items that were updated by function pathauto_post_update_remove_uuid_config_key() seem OK. Could the logic of that function be applied to all patterns?
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork pathauto-3588582
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
mably commentedComment #5
mably commentedComment #6
mably commentedHi @kenwest,
Thanks for the report. The fix is up as MR !171. Tracing how the YAML in your pattern can end up with a numeric key (
-list-form rather than a UUID-keyed map), one in-tree origin is the migrate source plugin atsrc/Plugin/migrate/source/PathautoPattern.phpline 132, which wraps the migrated condition with$row->setSourceProperty('selection_criteria', [$selection_criteria]). Any pathauto pattern that came over via a Drupal-7-to-Drupal-8/9/10/11 migration ends up with that shape on disk.Two questions:
The fix has two parts: a falsy-zero check that prevents the duplication itself, and a defensive normalization that rekeys any non-UUID condition id to a UUID on first save through the edit form, so the on-disk shape matches what the rest of the codebase assumes.
Comment #7
kenwest commentedHi @mably,
Comment #8
kenwest commentedI just read the remark "defensive normalization that rekeys any non-UUID condition id to a UUID on first save through the edit form". The point 3 in my previous comment was not the "first edit" so that might explain the failure I described. Here's what I did ...
Comment #9
kenwest commentedI re-ran the test but still get the problem I describe in point 3 in #7. Here's what I did this time (this should replicate the experience of someone like me) ...
Comment #10
mably commentedHi @kenwest can you give a try to the latest version of the MR?
Comment #11
kenwest commentedHi @mably,
I tested the latest version of the MR and it successfully handles the following 4 cases (these are content types each with a pattern) ...
Before applying the patch: the Blog and Office patterns used UUID keys; the Event pattern used numeric keys; and the Course pattern duplicated numeric and UUID keys and no numeric keys.
After applying the patch, I edited each pattern and saved it with no changes. All patterns were saved with UUID keys.