Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #2264 Migrate path aliases for nodes if they exist, otherwise turn on Pathauto. #2281

Merged
merged 7 commits into from
Mar 29, 2023

Conversation

trackleft
Copy link
Member

@trackleft trackleft commented Mar 8, 2023

Description

This PR checks the alias field for nodes on the source site during a migration, and determines whether to turn on Pathauto or not, on a node by node basis.

Related issues

Closes #2264

How to test

Run az_migration
See paths migrated, or Pathauto turned on.

Types of changes

Arizona Quickstart (install profile, custom modules, custom theme)

  • Patch release changes
    • Bug fix
    • Accessibility, performance, or security improvement
    • Critical institutional link or brand change
    • Adding experimental module
    • Update experimental module
  • Minor release changes
    • New feature
    • Breaking or visual change to existing behavior
    • Upgrade experimental module to stable
    • Enable existing module by default or database update
    • Non-critical brand change
    • New internal API or API improvement with backwards compatibility
    • Risky or disruptive cleanup to comply with coding standards
    • High-risk or disruptive change (requires upgrade path, risks regression, etc.)
  • Other or unknown
    • Other or unknown

Drupal core

  • Patch release changes
    • Security update
    • Patch level release (non-security bug-fix release)
    • Patch removal that's no longer necessary
  • Minor release changes
    • Major or minor level update
  • Other or unknown
    • Other or unknown

Drupal contrib projects

  • Patch release changes
    • Security update
    • Patch or minor level update
    • Add new module
    • Patch removal that's no longer necessary
  • Minor release changes
    • Major level update
  • Other or unknown
    • Other or unknown

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@trackleft
Copy link
Member Author

I'm going to try this

  path/pathauto:
    - plugin: str_replace
      regex: true
      source: alias
      search: /./
      replace: 0
    - plugin: default_value
      default_value: 1
  path/alias:
    plugin: skip_on_empty
    source: alias
    method: process

@trackleft
Copy link
Member Author

trackleft commented Mar 8, 2023

The above didn't work, but the following does.

  path/pathauto:
    -
      plugin: str_replace
      regex: true
      source: alias
      search: /.*$/
      replace: 0
    -
      plugin: default_value
      default_value: 1
    -
      plugin: static_map
      map:
        '00': 0
        '0': 0
        '1': 1
  path/alias:
    plugin: skip_on_empty
    source: alias
    method: process

When path alias DOES NOT EXIST on source site.

image

^ "|                             $Source                               |"
^ "---------------------------------------------------------------------"
  

^ "---------------------------------------------------------------------"
^ "|                           $Destination                            |"
^ "---------------------------------------------------------------------"
  "path" => array:1 [
    "pathauto" => 1
  ]

When a path alias EXISTS on source site.

image

^ "|                             $Source                               |"
^ "---------------------------------------------------------------------"
  "alias" => "/projects/alumni/2020/ampersand-modern-workspace-campus"

^ "---------------------------------------------------------------------"
^ "|                           $Destination                            |"
^ "---------------------------------------------------------------------"
  "path" => array:2 [
    "pathauto" => 0
    "alias" => "/projects/alumni/2020/ampersand-modern-workspace-campus"
  ]

Other things to consider:

Default value is set to '1' if fed a 0
Normally the str_replace returns '00', not sure why the regex is doing that.
search: /.*/ also returns '00' if a value exists in alias

@trackleft trackleft changed the title Initial fix for path alias Migrate path aliases for nodes if they exist, otherwise turn on pathauto. Mar 9, 2023
@trackleft trackleft marked this pull request as ready for review March 9, 2023 16:08
@trackleft trackleft requested a review from a team as a code owner March 9, 2023 16:08
@trackleft trackleft changed the title Migrate path aliases for nodes if they exist, otherwise turn on pathauto. Closes #2264 Migrate path aliases for nodes if they exist, otherwise turn on pathauto. Mar 9, 2023
@trackleft trackleft changed the title Closes #2264 Migrate path aliases for nodes if they exist, otherwise turn on pathauto. Closes #2264 Migrate path aliases for nodes if they exist, otherwise turn on Pathauto. Mar 9, 2023
@trackleft trackleft added bug Something isn't working migration Related to the D7 to D9 migration patch release Issues to be included in the next patch release labels Mar 9, 2023
@trackleft trackleft changed the title Closes #2264 Migrate path aliases for nodes if they exist, otherwise turn on Pathauto. Fixes #2264 Migrate path aliases for nodes if they exist, otherwise turn on Pathauto. Mar 9, 2023
joeparsons
joeparsons previously approved these changes Mar 10, 2023
@trackleft trackleft changed the title Fixes #2264 Migrate path aliases for nodes if they exist, otherwise turn on Pathauto. Migrate path aliases for nodes if they exist, otherwise turn on Pathauto. Mar 10, 2023
@joeparsons joeparsons changed the title Migrate path aliases for nodes if they exist, otherwise turn on Pathauto. Closes #2264 Migrate path aliases for nodes if they exist, otherwise turn on Pathauto. Mar 15, 2023
@trackleft trackleft added the backport Changes to be back-ported to previous minor release branch label Mar 15, 2023
@joeparsons joeparsons merged commit 6e5c21d into main Mar 29, 2023
@joeparsons joeparsons deleted the issue-2264 branch March 29, 2023 17:30
trackleft added a commit that referenced this pull request Apr 3, 2023
@trackleft trackleft mentioned this pull request Jun 16, 2023
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Changes to be back-ported to previous minor release branch bug Something isn't working migration Related to the D7 to D9 migration patch release Issues to be included in the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Node migrations don't import path alias.
4 participants