Unable to change the author of content using views/action

Created on 21 June 2019, over 5 years ago
Updated 18 April 2023, over 1 year ago

I want to change the author of multiple nodes using the action module. I have set up a new action by going to /admin/config/system/actions and then selecting "CREATE AN ADVANCED ACTION" and then "Change the author of content...".

In my view of the content type, I have added the "Node operations bulk form" field.

When I try to update any content using this method I get the error "No access to execute Change the author on the Content [TITLE]'. It happens when a content belongs to the anonymous user.

I have looked at the code that generates this error - it is in AssignOwnerNode.php

  /**
   * {@inheritdoc}
   */
  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
    /** @var \Drupal\node\NodeInterface $object */
    $result = $object->access('update', $account, TRUE)
      ->andIf($object->getOwner()->access('edit', $account, TRUE));

    return $return_as_object ? $result : $result->isAllowed();
  }

Not sure, why do we need to check permissions to edit the owner to change the owner of the node.

If I delete an inappropriate piece of code, it works. this is the new code:

  /**
   * {@inheritdoc}
   */
  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
    /** @var \Drupal\node\NodeInterface $object */
    $result = $object->access('update', $account, TRUE);

    return $return_as_object ? $result : $result->isAllowed();
  }
🐛 Bug report
Status

Closed: duplicate

Version

10.1

Component
Node system 

Last updated 4 days ago

No maintainer
Created by

🇺🇦Ukraine lobodacyril

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India arunkumark Coimbatore

    The latest version of Drupal core released. So, moving the issue to 10.1.x version.

    I tested the patch with the Drupal 10.0.1 version. The patch was applied successfully. But still, the issue persists with the core System Actions on Node operations bulk form. Attached screenshot of the Views fields for the bulk operation.

    But when we are using the contributed module VBO will help to attach the additional system actions.

  • Status changed to Closed: duplicate over 1 year ago
  • 🇳🇿New Zealand danielveza Brisbane, AU

    On another review - This appears to be a duplicate of 🐛 Allow user to change author if they have the edit access Needs work . That issue has a very similar patch and a test so progress on this issue should continue there.

Production build 0.71.5 2024