I have the realname module installed on my site to display authors by their realname instead of username. But this is not working for the feed I created in views. The XML generated has the username for the creator for each article. For example:
<dc:creator>daviser</dc:creator>

The creator is set in modules/node/views_plugin_row_node_rss.inc
I found that if I change this

      'key' => 'dc:creator',
        'value' => $node->name,

to

        'key' => 'dc:creator',
        'value' => format_username($node),

then the realname is used for the creator.

<dc:creator>Ellen Davis</dc:creator>

Issue fork drupal-1460506

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

dawehner’s picture

Well views follows the drupal way:

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

see node_feed(), maybe it should be changed in core as well.

merlinofchaos’s picture

Yes it absolutely should be fixed. We should always be using format_username where a username is visible. We should fix this and a bug can be filed against core.

ellen.davis’s picture

So... what is needed here to get this fixed in views?

Does the core bug need to be fixed first? Do I need to file a bug against core? (I have never done that before, so unsure of process)

Do I need to supply a patch for views?

dawehner’s picture

You would have to probably fix this in both places, so it would make sense to create an issue against core, and provide a patch against views.

ellen.davis’s picture

StatusFileSize
new491 bytes

I've submitted an issue against core.

Here is the patch for views.

Lloyd’s picture

Will the patch fix this issue prior to the core issue being resolved?

ellen.davis’s picture

Yes. The patch simply makes the change that I posted in this issue summary. It is not dependent on the core issue being patched.

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new1021 bytes

Added format_username to row_comment as well.

Set to needs review to let the testbot look at the patch.

dave reid’s picture

Since the output of format_username is untrusted and should be escaped before output, do we need to add a check_plain() here or it it escaped later in the RSS render?

dawehner’s picture

Yes it's runned through check_plain:

template_preprocess_views_view_row_rss -> empty($item->elements) ? '' : format_xml_elements($item->elements); -> runs check plain on the values.

damiankloip’s picture

This looks good, and handy to me.

dave reid’s picture

Status: Needs review » Needs work
+++ b/modules/comment/views_plugin_row_comment_rss.incundefined
@@ -107,7 +107,7 @@ class views_plugin_row_comment_rss extends views_plugin_row {
+        'value' => format_username($comment->name),

This should be format_username($comment)

ellen.davis’s picture

Status: Needs work » Needs review
StatusFileSize
new1015 bytes

Updated patch to use format_username($comment)

ultimike’s picture

Just tested this patch, looks great!

Thank you!
-mike

ellen.davis’s picture

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

Lostboy22’s picture

Category: feature » bug
Priority: Normal » Major

Tired of having to look this up for each new release!

Lostboy22’s picture

Issue summary: View changes

putting code in code tags

hass’s picture

Added related core issue

hass’s picture

2 years RTBC? Why is this not commited?

nmillin’s picture

Patch views-format-username-1460506-13.patch works for me.

  • dawehner committed 10e71bd on 7.x-3.x authored by ellen.davis
    Issue #1460506 by ellen.davis, dawehner: use format_username for RSS...
dawehner’s picture

Project: Views (for Drupal 7) » Drupal core
Version: 7.x-3.x-dev » 8.0.x-dev
Component: feed displays » views.module
Status: Reviewed & tested by the community » Patch (to be ported)

Seems legit.

2 years RTBC? Why is this not commited?

You know the answer, don't you?

jibran’s picture

Title: use format_username for RSS feed creator » Use AccountInterface::getUsername() for RSS feed creator
Status: Patch (to be ported) » Needs review
StatusFileSize
new516 bytes

Form \Drupal\node\Plugin\views\row\Rss


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

So only \Drupal\comment\Plugin\views\row\Rss needs fix.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +VDC

Looks alright for me!

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

This looks testable.

catch’s picture

Title: Use AccountInterface::getUsername() for RSS feed creator » Use AccountInterface::getDisplayName() for RSS feeds in Views
andypost’s picture

+++ b/core/modules/comment/src/Plugin/views/row/Rss.php
@@ -95,7 +95,7 @@ public function render($row) {
+        'value' => $comment->getOwner()->getUsername(),

suppose getDisplayName() should be used here

And extend \Drupal\comment\Tests\Views\RowRssTest

andypost’s picture

Also anonymous comments mostly use user-entered name!
So better use getDisplayName() only for comment that has anonymous author and name field is empty

jibran’s picture

Status: Needs work » Needs review
StatusFileSize
new516 bytes

Reroll.

andypost’s picture

Status: Needs review » Needs work
+++ b/core/modules/comment/src/Plugin/views/row/Rss.php
@@ -93,7 +93,7 @@ public function render($row) {
-        'value' => $comment->getAuthorName(),
+        'value' => $comment->getOwner()->getUsername(),

getUsername deprecated

oleksiy’s picture

Updated using getDisplayName() + tests.

oleksiy’s picture

Status: Needs work » Needs review
dawehner’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests

+1, we have tests and the bugfix is basically confirmed by @andypost.
I don't really see why this issue is major, but well, let's just keep that :)

andypost’s picture

yep, +1 on that

andypost’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Sorry, but I need to ask extend tests because of #2614504: Values of 'name' & 'email' fields should be NULL when comment has author (uid > 0)
We need to another test to make sure that comment author of anonymous user is displayed (author name for anonymous should use own name base-field)
@dawehner that's interesting case when author name should be loaded from denormalized field, so probably require to extend views plugin to load extra data or use comment method properly

dawehner’s picture

@dawehner that's interesting case when author name should be loaded from denormalized field, so probably require to extend views plugin to load extra data or use comment method properly

Well, this sounds like a general problem of comments itself. $comment->getOwner() should return an object which has the right username for the appropriate context, shouldn't it?

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dawehner’s picture

Priority: Major » Normal

@alexpott, @timplunkett, @xjm, and I discussed this issue awhile back at DrupalCon New Orleans.

We agreed that this is a clear bug we should fix, but we don't think this is a major bug, according to our issue priorities.

@dawehner that's interesting case when author name should be loaded from denormalized field, so probably require to extend views plugin to load extra data or use comment method properly

+++ b/core/modules/comment/src/Plugin/views/row/Rss.php
@@ -93,7 +93,7 @@ public function render($row) {
-        'value' => $comment->getAuthorName(),
+        'value' => $comment->getOwner()->getDisplayName(),
       ),

As @andypost explained, we could do a preload, so we don't load each one individually. On the other hand, we store those entries in cache so it is less of a problem. Note: Normal formatters do the preloading on their own

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Looks like this is still relevant.

I found a related issue.

andregp’s picture

StatusFileSize
new815 bytes
new1.3 KB
new2.29 KB

Just a crude reroll. I tried to address the remaining problems, but couldn't. One concern that raised though is about the current test. I tested locally and it passed even without the fix on Rss.php.

Still needs work to address #35, #36, and #38.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

acbramley’s picture

Issue tags: +Needs reroll

Needs a reroll on 11.x on an MR.

el7cosmos made their first commit to this issue’s fork.

xjm’s picture

Adding credits from triage review posted by @dawehner in #38.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.