[author-name] & [author-name-raw] don't populate for Anonymous User

ChrisRut - September 24, 2009 - 16:25
Project:Token
Version:6.x-1.12
Component:Token Actions
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

I've setup PathAuto for my custom content type as follows: customcontenttype/[yyyy]/[mm]/[dd]/[author-name-raw]/[title-raw]
I've also tried using the non raw version of author-name as the PathAuto: customcontenttype/[yyyy]/[mm]/[dd]/[author-name]/[title-raw]
But it still won't create a listing for anonymous. Instead Anonymous user posts are placed in: I've also tried using the non raw version of author-name as the PathAuto: customcontenttype/[yyyy]/[mm]/[dd]/[title-raw] (notice there is no [author-name]).

See also: http://drupal.org/node/586828

#1

ChrisRut - September 24, 2009 - 16:28

Oops, I copy and pasted that line incorrect, it should be:
But it still won't create a listing for anonymous. Instead Anonymous user posts are placed in: "customcontenttype/[yyyy]/[mm]/[dd]/[title-raw]" (notice there is no [author-name]).

#2

ChrisRut - September 29, 2009 - 14:25

Also wanted to point out...
I created a view similar to a blog:
Node: created year
Node: created month
Node: created day
User: Name
Arguments Screenshot

So "/2009/09/23/Administrator" will list all the nodes created by the Administrator on 9/23/09, and "/2009/09/23/" should list all the users who created nodes on 9/23/09, however there is a catch, if the node was created by an "Anonymous" user, there is no link.
Screenshot - Notice there is a listing for Administrator, and it looks like the administrator posted 3 nodes, and there is another user with NO TITLE who posted 1 (that is the Anonymous Post).
And when I go to the node manually, and I see it is located at "customcontenttype/[yyyy]/[mm]/[dd]/[title-raw]", notice there is no [author-name] in there.

#3

ChrisRut - October 30, 2009 - 17:29

The corresponding lines of code are: (grep -inr "author" .)

./token_node.inc:33:      $values['author-uid']       = $node->uid;
./token_node.inc:34:      $values['author-name']      = check_plain($account->name);
./token_node.inc:35:      $values['author-name-raw']  = $account->name;
./token_node.inc:36:      $values['author-mail']      = check_plain($account->mail);
./token_node.inc:37:      $values['author-mail-raw']  = $account->mail;

Would it be possible to add the following check:

<?php
if (empty($account->name)) {
$values['author-name']  = "Anonymous";
$values['author-name-raw'] = "Anonymous";
}
?>

#4

ChrisRut - October 30, 2009 - 17:29

:delete:

#5

ChrisRut - September 29, 2009 - 15:26
Status:active» needs review

See attached patch.
Worked for me.
Needs Review

AttachmentSize
token_node.inc_.patch 710 bytes

#6

ChrisRut - September 29, 2009 - 17:23

I also found another solution that works thanks to merlinofchaos on IRC: Simply change the MySQL DB table "users" where "UID" = 0 set "name" = Anonymous

 
 

Drupal is a registered trademark of Dries Buytaert.