Problem/Motivation

Usernames printed by node_feed() can't be altered by other modules. In 7.x this is due to the omission of format_username().

Proposed resolution

8.x is being patched as part of #421586: Author nevertheless displayed in RSS feeds if disabled for privacy reasons.

Use format_username() in 7.x.

Remaining tasks

Make the changes mentioned in #7 to the 7.x patch in #3.

Original report by @versvs

Hi,

before starting, thanks for building this module that does only one thing but does it pretty well :)

Now, my question. Maybe it is me but I dont find how to make the Real Name to display in feed items. While it shows properly whenever the user is invoked, it fails to replace the user name when the nodes are showed as part of any RSS.

Any ideas? Maybe it is something that can be achieved by tinkering with the options, I just didn't find it. I also find it surprising that searching for "feed" or "rss" didn't help. As I think that I'm asking for something that's not that strange, It appears to me that the answer is probably too obvious for anyone to ask. So if this is the case, sorry for the inconvenience. Any help will be appreciated.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

versvs’s picture

I found this thread on views, but this is definetily related issue. I'm finding my problem in the main drupal feed (drupalsite/rss.xml), which (as far as I believe) i did not replace with a view...

http://drupal.org/node/1460506

hass’s picture

Title: Show Real Name in RSS Feed » RSS: Use format_username() for username
Project: Real Name » Drupal core
Version: 7.x-1.0 » 7.x-dev
Component: Tokens » node.module
Category: Support request » Bug report
Issue summary: View changes

Moving to core.

node_feed() is not using format_username() in array('key' => 'dc:creator', 'value' => $node->name), what prevents realname module for changing the username to a real name.

hass’s picture

Status: Active » Needs review
FileSize
955 bytes

This patch should do the trick, but has not been tested.

Lostboy22’s picture

Component: node.module » ajax system

Works well with 7.27 and 7.28

I don't change node.module to ajax system, unless retesting did that.

hass’s picture

Component: ajax system » node system
dcam’s picture

Title: RSS: Use format_username() for username » Make usernames in node_feed() alterable
Version: 7.x-dev » 8.x-dev
Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Novice

Edit: 8.x is being patched in another issue.

I may be wrong, but I think 8.x has the same issue. Here is the same line in 8.x:

array('key' => 'dc:creator', 'value' => $node->getOwner()->label()),

I checked the User entity class and found that getUsername() is what allows other modules to alter the usernames for display like format_username() does in 7.x. There's an issue just like this for comment_preview(), but someone posted that 8.x's comment_preview() was already fixed. I checked it and it does use getUsername(). So, I think 8.x node_feed() probably needs to be changed, but someone should verify that.

As for the 7.x patch, we have the user ID in $node->uid.

+++ b/modules/node/node.module
@@ -2606,9 +2606,10 @@
+    $account = user_load_by_name($node->name);

Let's use user_load($node->uid) here instead of user_load_by_name(). I don't know which would be the faster query, but user_load_by_name() calls user_load_multiple() with its $conditions argument which is deprecated. It's probably a moot point given that 8.x is mostly built and so different, but I'd still rather use user_load().

dcam’s picture

Title: Make usernames in node_feed() alterable » Use format_username() in node_feed()
Version: 8.x-dev » 7.x-dev
Issue summary: View changes
Related issues: +#421586: Author nevertheless displayed in RSS feeds if disabled for privacy reasons

I should have searched for duplicate issues before posting all that. See #421586-21: Author nevertheless displayed in RSS feeds if disabled for privacy reasons where it was decided not to combine the two issues. 8.x is being fixed there, so I'm bringing this one back to 7.x.

er.pushpinderrana’s picture

Status: Needs work » Needs review
FileSize
629 bytes
1.21 KB

In this patch, use user_load($node->uid) here instead of user_load_by_name(). Please review updated patch.

Status: Needs review » Needs work
dcam’s picture

+++ b/modules/node/node.module
@@ -2604,9 +2604,10 @@ function node_feed($nids = FALSE, $channel = array()) {
+    $account = user_load_by_name($node->name);

Sorry, I guess I wasn't clear. I meant user_load_by_name() should be replaced by user_load() on this line that is being added by the patch.

amit.drupal’s picture

Use function user_load_by_name($node->name); for load user.

Please review patch.

er.pushpinderrana’s picture

@amit.drupal, first of all thanks for updating the patch.

@dcam, thankyou so much for correcting me. You were clear but I missed your point, sorry for that (-:.

Thanks again!

hass’s picture

Status: Needs review » Needs work

The correct base patch is #3

er.pushpinderrana’s picture

Status: Needs work » Needs review
FileSize
762 bytes
1.06 KB

ohh.... @hass thankyou, I also dint review @amit.drupal patch due to lack of interdiff file. I think as I understood, we just need to change the following line, please review updated patch.

+++ b/modules/node/node.module
@@ -2604,9 +2604,10 @@ function node_feed($nids = FALSE, $channel = array()) {
+    $account = user_load_by_name($node->name);

dcam’s picture

That's better. Once #15 comes back green I'll RTBC it.

Status: Needs review » Needs work

The last submitted patch, 12: drupal7-use-format-username-foruser-1640404-issues-12.patch, failed testing.

dcam’s picture

Status: Needs work » Needs review

I have no idea what went on with the file hiding. I think all this cross-posting is freaking out the comment form. I'm going to set this back to Needs Review so hopefully Testbot will pick #15 back up.

dcam’s picture

Re-uploading #15 due to wierdness with the comment form that caused it to be hidden/deleted. I am not the author of this patch and it should not be attributed to me.

dcam’s picture

Status: Needs review » Reviewed & tested by the community

#15 (re-uploaded in #19) is RTBC.

Status: Reviewed & tested by the community » Needs work

Status: Needs work » Needs review
dcam’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

Status: Needs work » Needs review
dcam’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work
hass’s picture

Status: Needs work » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work
hass’s picture

Status: Needs work » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

Status: Needs work » Needs review
dcam’s picture

Status: Needs review » Reviewed & tested by the community
David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed

As far as I can see, there is no such bug in Drupal 8 (and the issue linked to above is fixing something else)...

Therefore, committed to 7.x - thanks!

  • David_Rothstein committed 766312e on 7.x
    Issue #1640404 by er.pushpinderrana, dcam, amit.drupal, hass | versvs:...

Status: Fixed » Closed (fixed)

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