Problem/Motivation

1. When using Quick Node Clone, the validation is not applied because the module only checks for 'default' and 'edit' form operations.
2. Additionally, some pathauto patterns use tokens like [node:menu-link:*] which call toUrl() internally. For new/cloned entities, this throws an EntityMalformedException because the entity doesn't have an ID yet.

Steps to reproduce

With unique_alias_checker installed & enabled, clone a node using Quick Node Clone. New cloned node will have -0 appended to URL, indicating a duplicate URL exists.

Proposed resolution

1. Add 'quick_node_clone' to the list of allowed form operations.
2. Handle new entities by setting $source to NULL and wrapping token replacement in try/catch. If token replacement fails due to menu-link tokens, fall back to a pattern without those tokens.

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

calvin.horsford created an issue. See original summary.

calvin.horsford’s picture

Status: Active » Needs review

Created merge request. This adds 'quick_node_clone' to the list of form operations that trigger validation, allowing the module to work with Quick Node Clone.

calvin.horsford’s picture

Issue summary: View changes

avpaderno made their first commit to this issue’s fork.

mdranove’s picture

Status: Needs review » Needs work

I tested this out on a drupal 11 install. Was able to repro the two issues.

Here's what I found.

  • The MR fixes the issue with quick_node_clone, it does prevent new dupe aliases from being created.
  • The MR partially addresses the second issue, nodes with [node:menu-link:*] tokens. However, I'm not sure this fix is complete. For example, I setup the following pathauto pattern: [node:menu-link:menu:description]/[node:field_tags]. I then attempted to save a new node using this pattern and got the dupe alias error message even though I had no existing node using the tag in question. So this works well if there only a [node:menu-link:*] token, however combined with other tokens in the path it's not a complete fix/introduces a different kind of issue.
mdranove’s picture

Status: Needs work » Reviewed & tested by the community

I went back in to look at this again and couldnt repro the issue I mentioned above. Thanks for adding the gitlab file, ill fix those as part of this. Moving into rtbc temporarily.

  • mdranove committed aa7d9355 on 1.4.x authored by avpaderno
    Issue #3583789: Fix Entity MalformedException for cloned/new entities
    
mdranove’s picture

Status: Reviewed & tested by the community » Fixed

Actually going to do phpstan in a separate ticket.

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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.