After writing a new article and publishing it i can't change the author of the the article afterwards.

This happened after a fresh installation with the following core modules activated:

Blog
Forum
Poll
Content translation
Profile

CommentFileSizeAuthor
#6 node_author_update.patch1.13 KBbleen
#1 node_author.patch859 bytesmarcingy
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

marcingy’s picture

Title: Can't change author after article is published » Nodes with a $node->uid assigned can not have author changed
Assigned: honorfield » Unassigned
Status: Active » Needs review
FileSize
859 bytes

If an attempt is made to amend an author it will fail because of this piece of logic

if (user_access('administer nodes') && !isset($node->uid)) {
    if ($account = user_load_by_name($node->name)) {
      $node->uid = $account->uid;
    }
    else {
      $node->uid = 0;
    }
  }

In that an existing node will always fail the second part of the if statement. D6 makes no check at all except for user_access which in theory could see a node assigned to uid = 0. My intial thoughts are that we should split out the if statement into 2 checks so as if we don't find a name we don't overwrite the existing uid. Patch attached.

marcingy’s picture

Priority: Normal » Critical

On second thought this really is critical as the idea that a node can never change ownership after creation is a pretty fundamental flaw.

zenith.thepeak’s picture

Title: Nodes with a $node->uid assigned can not have author changed » Nodes with a $node->uid assigned can make the author changed
Assigned: Unassigned » zenith.thepeak
Status: Needs review » Reviewed & tested by the community

yeah, i have tried the code and i am able to Change the Author name.
Its working

int’s picture

Assigned: zenith.thepeak » Unassigned

The "Assigned to", is to tell that person is working in one patch, and not testing.

bleen’s picture

Title: Nodes with a $node->uid assigned can make the author changed » Nodes with a $node->uid assigned can not have author changed

...and the issue title should describe the problem (even after a potential fix has been identified)

bleen’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.13 KB

a) the patch in #1 needs to be created relative to the root of the Drupal install (not modules/node). I rerolled the patch from #1 to reflect this

b) the patch seems to fix the problem - woohoo!!!

c) I am concerned about this line in the comments above the lines being patched though:

// user ID, unless we've already been provided a user ID by other means.

What "other means"? If contrib modules (for example) are assigning a $node->uid, but not a $node->name then this change will cause that to stop working. I can imagine "devel generate" might do this. Gonna check... but I'd love to hear from someone else on this. I may be completely wrong here.

matt2000’s picture

Status: Needs review » Closed (duplicate)

I created this bug in #398110: node_submit resets $node->uid ... sorry... It was first reported there. Moshe makes the solution clear in the comments: node_submit needs to go away completely. I've been meaning to write the patch, but haven't got to it yet.

Dries’s picture

Status: Closed (duplicate) » Needs work

If this code is correct, the PHP comment directly above should be updated.

matt2000’s picture

Status: Needs work » Closed (duplicate)

The PHP comment is removed in the new patch provided in the original issue queue.

David_Rothstein’s picture

Status: Closed (duplicate) » Fixed

Looks like this was all fixed by the latest commit at #492186: Authoring information is never updated., although the bug report here was older.

Status: Fixed » Closed (fixed)
Issue tags: -author, -article

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