Problem/Motivation

When attempting to execute the replicate action, access is denied. This is because EntityReplicate::access creates a route with a path that is the $entity_type_id, in node's case this translates to /node which returns neutral from the 2 fake routes in ReplicateAccessChecker::access.

Steps to reproduce

Try to use the Replicate action (called Delete in the latest stable version, see #3240883: Incorrect system action label)

Proposed resolution

While I don't fully understand why access is setup this way (we could simply do $object->access() chaining), a simple fix is copying what the RouteSubscriber does and use

        $base_path = $entity_type->getLinkTemplate('canonical');
        $path = $base_path . '/replicate';
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

acbramley created an issue. See original summary.

acbramley’s picture

Project: Replicate » Replicate UI

Sorry, meant to be in Replicate UI.

acbramley’s picture

Status: Active » Needs work
Issue tags: +Needs tests

Still needs tests but here we go.

acbramley’s picture

Title: EntityReplicate action ::access is broken » EntityReplicate action is broken

Actually this whole action is broken.

  public function execute($object = NULL) {
    $this->executeMultiple([$object]);
  }

This is a recursive loop, ActionBase::executeMultiple does this:

  public function executeMultiple(array $entities) {
    foreach ($entities as $entity) {
      $this->execute($entity);
    }
  }
rcodina’s picture

Status: Needs work » Needs review

The patch from the MR works like a charm!

anybody’s picture

Status: Needs review » Reviewed & tested by the community

Nice work @acbramley! Works like a charm. Still this has the "Needs tests" tag - would you like to move it back to NW and add the missing tests or how to proceed?

anybody’s picture

Status: Reviewed & tested by the community » Fixed

Thank you all! Merged!

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.

acbramley’s picture

Status: Fixed » Needs work
Issue tags: -Needs tests

It doesn't look like the commit was pushed?

  • berdir committed d5bd572b on 8.x-1.x authored by acbramley
    feat: #3372362 EntityReplicate action is broken
    
    By: @acbramley
    By: @...
berdir’s picture

Status: Needs work » Fixed

Merged it now.

@Anybody: Looks like your other merges also didn't happen. I also recommend using the new commit format, update the contribution record first and then copy the commit message there.

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.

anybody’s picture

Thanks @berdir indeed. I used the merge train and it looks like it failed, sorry... Seems to have been Deutsche Bahn, not reliable Swiss Rhätische Bahn ;)

Status: Fixed » Closed (fixed)

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