Problem/Motivation
Core is about to add a default content export system: #3532694: Add a command-line utility to export content in YAML format
It is extensible and modules can integrate with it by means of an event. Pathauto should integrate with this new system.
Proposed resolution
It is possible that nothing will actually be necessary; core naïvely exports the Path field items, only removing the non-portable path ID.
But if it turns out that core is not exporting the Pathauto flag, then Pathauto should subscribe to the new PreExportEvent and wrap around the core callback for path field items, ensuring that the flag is preserved on export.
Issue fork pathauto-3535498
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 #2
phenaproximaThe core blocker is in!
Comment #3
dieterholvoet commentedFYI, it seems like core is not exporting the Pathauto flag by default.
Comment #4
phenaproximaThat's because it is a computed property, which core ignores by default.
Pathauto could force the property to be exported by overriding the export callback for
pathfield items. That's doable by subscribing toPreExportEvent.Comment #5
dieterholvoet commentedComment #7
dieterholvoet commentedPathauto seems to be causing issues with default content.
Drupal\pathauto\PathautoItem::postSave()makes it so its parent method,Drupal\path\Plugin\Field\FieldType\PathItem::postSave(), is never triggered when pathauto is enabled. This causes aliases of translations to sometimes not be imported.Comment #8
dieterholvoet commentedIt seems like #2973478: Aliases are not created for affected translations fixes this problem. With a patch from that issue, aliases for all translations are generated during import. That does mean that the exported alias is not used and instead a new alias is generated, but that might be acceptable in context of Pathauto.
Comment #9
csakiistvan@dieterholvoet — could you clarify the last sentence of comment #8? "The exported alias is not used and instead a new alias is generated" only holds for
pathauto: 1items; forpathauto: 0the exported alias is used verbatim, which is what this MR makes possible. Also, should #2973478 be a dependency rather than related, if the translation import fix is required?✅ Tested and works — applied MR !185, rebuilt caches and exported two nodes with core's
Exporter: thepathfield now carriespathauto: 1/pathauto: 0and nopid. An export → delete → import round trip kept/my-hand-made-aliason the manual node; the same YAML without thepathautolines replaced it with/article/manual-alias-test.Notes
Comment #10
dieterholvoet commentedYes
Yes, it's needed when dealing with translations, but that doesn't mean we can't merge this before that one.