Problem/Motivation

Core's default content exporter excludes computed properties, so the pathauto state is lost.
On import, pathauto then regenerates manual aliases.

Steps to reproduce

  1. Create a node with a manual alias and "Generate automatic URL alias" unchecked.
  2. Export it with drush content:export, delete it, and import it again.
  3. The alias is replaced by one from the pattern.

Proposed resolution

Export the pathauto state from a PreExportEvent subscriber, as the contrib Default Content module does. Includes a kernel test.

Remaining tasks

Review.

User interface changes

None.

API changes

None.

Data model changes

None.

Issue fork pathauto-3626992

Command icon 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

herved created an issue. See original summary.

herved’s picture

Status: Active » Needs review
csakiistvan’s picture

Assigned: Unassigned » csakiistvan
csakiistvan’s picture

✅ Tested and works — exported a node with a manual alias (/my-manual-alias, automatic alias unchecked) with vendor/bin/dr content:export, deleted it and imported it with core's Importer: before MR !189 the export had no pathauto key and the import produced the pattern alias with pathauto on. After applying the MR and rebuilding caches, the export contains pathauto: 0 and the imported node keeps /my-manual-alias, so the manual alias survives the round trip.

Notes
  • Drush has no content:export command here; the exporter is core's console command (vendor/bin/dr content:export node <nid>, or the deprecated core/scripts/drupal).
➜  tester bash .test-issue/pathauto/repro-3626992.sh before

Running WITHOUT MR !189
Created node 7570 with alias /my-manual-alias
Exported path field:
  path:
    -
      alias: /my-manual-alias
      langcode: en
Imported node 7571 alias: /repro/manual-alias-3626992 pathauto: 1
 [notice] Message: ECA 3590467: negated condition returned TRUE

MR !189 restored.
➜  tester bash .test-issue/pathauto/repro-3626992.sh       

Running WITH MR !189
Created node 7572 with alias /my-manual-alias
Exported path field:
  path:
    -
      alias: /my-manual-alias
      langcode: en
      pathauto: 0
Imported node 7573 alias: /my-manual-alias pathauto: 0
 [notice] Message: ECA 3590467: negated condition returned TRUE
csakiistvan’s picture

Assigned: csakiistvan » Unassigned
Status: Needs review » Reviewed & tested by the community