Problem/Motivation

I have a node content type with a pattern like this:

[node:field_ref_term:entity:field_text_url_path]/[node:field_text_url_path]

When I save a node manually, the URL alias is updated correctly.

When I import nodes with Feeds, the URL alias is updated correctly.

When I delete all aliases and use bulk regenerate to make more, the URL alias is updated correctly.

However, when I save a node programmatically like this:

      $node = Node::load($nid);
      $node->setChangedTime(\Drupal::time()->getRequestTime());
      $node->save();

Then the pathauto alias is "[node:field_ref_term:entity:field_text_url_path]-number", as there are several nodes with the same term reference, and the number is used to distinguish them.

Steps to reproduce

1. Create a content type with a taxonomy term reference.
2. Add a text field to the content type, "field_text_url_path".
3. Add a text field to the taxonomy vocabulary, "field_text_url_path".
4. Try saving a node of the content type with $node->save() as described above.

Issue fork pathauto-3265344

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

ptmkenny created an issue. See original summary.

rohit.rawat619’s picture

Assigned: Unassigned » rohit.rawat619

i Fix code by some function like pathauto_update_8100(){}

rohit.rawat619’s picture

Status: Active » Needs work
StatusFileSize
new23.81 KB

i Fix code by some function like pathauto_update_8100(){}

rohit.rawat619’s picture

Status: Needs work » Needs review
StatusFileSize
new23.81 KB

i Fix some code by pathauto_update_8100(){}
Kindly,Review this

rohit.rawat619’s picture

Assigned: rohit.rawat619 » Unassigned
ravimalviya2000’s picture

Hi,

On below issues some discussion done for node saving by programming.
issues : https://www.drupal.org/project/pathauto/issues/1462080

There triggered alias parameter when node save.

mably’s picture

Status: Needs review » Needs work

Patch is unreadable, too many unrelated changes.

Please provide MR.

mably’s picture

Status: Needs work » Closed (cannot reproduce)

Pushed a kernel test that tries to reproduce the above scenario without success.

So closing as "Cannot reproduce".

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.