Problem/Motivation

When you call "save()" function on an entity, Micro Path path is not updated.

Steps to reproduce

Enable Pathauto and Micro Path modules.
Create Basic Page node named "About".
Make a function where you load the node of "About" page to "$node".
Change the title of said node with "$node->setTitle('something new')".
Save node with "$node->save()".
Run the above code.
Check that the Micro Path path did not change.

Proposed resolution

When an entity is saved, check if it has a Pathauto pattern and if so, update the Micro Path path.

Issue fork micro_path-3361001

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

agile-mark-l created an issue. See original summary.

markman4897’s picture

markman4897’s picture

Status: Active » Needs review
flocondetoile’s picture

Status: Needs review » Active

Hi, implementing this hook means the alias is saved / updated twice if the entity is saved from its form. The first time by the widget element, and the second time by this hook.

What prevent you to run
Drupal::service('micro_path.pathauto_generator')->updateEntitySiteAlias($entity, $site_id, 'update');
just after programmatically call your node->save() ?