Closed (fixed)
Project:
Drupal core
Version:
8.5.x-dev
Component:
forum.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Dec 2011 at 13:57 UTC
Updated:
31 Mar 2018 at 19:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
larowlanWe need both, one is for the last comment, the other for the author. However the test pass intrigues me.
Comment #2
droplet commentedfor what author ??
for testing & coding side, it never get used:
Comment #3
heilop commentedComment #4
catchYep we never actually fetch the uid field from the {node} table here so it is indeed a pointless join.
Committed/pushed to 8.x, moving to 7.x for backport.
Comment #5
droplet commentedComment #6
andypostplease don't change alias name because contrib probably already alters this
Comment #7
droplet commented:)
Comment #8
andypostthanx, thats much better
Comment #9
David_Rothstein commentedI don't think it's true that this join is pointless. It's an inner join, which means it guarantees there's actually a matching row in the users table.
By guaranteeing that, it forces the query to be consistent with the one in forum_get_topics(), which also does this join. And we do want them to be consistent (since one query gets you information about the most recently commented-on post and the other shows a list of posts, so it would be pretty weird if the forum overview says "Last post: 5 minutes ago by X" but then you go to the forum and there is no such recently-updated post).
In practice, this can only occur if the node author is a user who no longer exists on the site... so it should be pretty rare. However, we do have situations where a user could have been deleted without the node module's hooks being fired to respond to it, so it definitely can happen.
Moving back for discussion, since the general point is that this query should be consistent with forum_get_topics() but the patch makes it not consistent.
Also, to be honest, I'm not that excited about committing the patch to Drupal 7 either way. It doesn't seem to be an actual bug (or a noticeable performance hit, at least not that I know of?), and as @andypost points out this is an alterable query (in fact, it's a node access query) so we're probably better off not changing those in Drupal 7 unless we have a good reason to.
Comment #10
salvisThis is broken in D7, and the patch has broken it even more for D8.
Let me explain for D7, because that is less broken — here's what we have:
ncs.last_comment_uidis never 0 (at least I have no such record in my database), so this always returnsu2.name, which is the name of the creator rather than the author.Here's how to reproduce the bug: as admin create a new topic and set Authored by to 'Bob'. Bob's name will show up as the author of the topic, but forum/% will show the admin's name instead.
The code above is obvious nonsense, but the u1/u2 idea is a good one — it has probably worked at some point. The correct code is:
We must check the comment_count! If there are no comments, then u1.uid / n.uid is the one to use, and only if there is at least one comment we get the comment author in u2.uid.
Besides the name we also need the uid. It is used to turn the user name on forum/% into a link to the user's profile page.
Here's the patch for D7 as explained above. Let's see what the testbot thinks of it.
(I know we'll need D8 first, and we'll need tests, obviously.)
Comment #11
salvisGood, now D8...
Comment #12
salvis#11: forum_author.1377468.11.D8.patch queued for re-testing.
Comment #13
salvis#11: forum_author.1377468.11.D8.patch queued for re-testing.
Comment #24
dillix commented