FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » New members with old posts linked in profile
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
New members with old posts linked in profile [message #21279] Wed, 24 November 2004 16:35 Go to next message
treebeard is currently offline  treebeard   United States
Messages: 44
Registered: April 2004
Location: Huge Universe
Karma: 0
Member
In the last few weeks at the ProSoundWeb forums, we've been seeing newly registered members whose profiles show someone else's old post as their last post; even weirder, all these Nov newbies' "last posts" seem to be in August 2004 (see: http://marsh.prosoundweb.com/index.php/ml/). Any idea why this would be happening? We have 5459 registered users and are running four forums against the same database (custom setup; Ilia knows the setup).
Re: New members with old posts linked in profile [message #21282 is a reply to message #21279] Wed, 24 November 2004 16:55 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
The cause is simple to explain.

The user database is shared but the message database is not, the users table happens to cache the id of the last message posted by the user.

Suppose a member posts a message inside forum A and you view their profile in forum B. If forum B has a message with the same id it'll point to that message even though it was not posted by the user.

The fix is to modify the code fetching the last post of the user on the profile page (usrinfo.php.t) to fetch this data from the database and not use the cache.


FUDforum Core Developer
Re: New members with old posts linked in profile [message #21288 is a reply to message #21282] Wed, 24 November 2004 17:48 Go to previous messageGo to next message
treebeard is currently offline  treebeard   United States
Messages: 44
Registered: April 2004
Location: Huge Universe
Karma: 0
Member
Thanks, Ilia. I didn't notice the post ID being the same. One of these newbies, for instance, posted message 30433 in the REP forum. In the sr forums there is no message with that ID, so there's no match, but in the MARSH forum there is a message with ID 30433, there's a match (although to someone else's post).

I'm a little lost in the solution, though. Any hints on how to do this modification?

Thanks!
Re: New members with old posts linked in profile [message #21289 is a reply to message #21288] Wed, 24 November 2004 17:55 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
If you open usrinfo.php.t file inside the src/ directory you will find the following condition:
if ($u->u_last_post_id) {

Inside this condition is the query and the code responsible for fetching the user's latest message.

You need to change the query in there to get the last post by looking directly inside the msg table.


FUDforum Core Developer
Re: New members with old posts linked in profile [message #21290 is a reply to message #21289] Wed, 24 November 2004 18:25 Go to previous messageGo to next message
treebeard is currently offline  treebeard   United States
Messages: 44
Registered: April 2004
Location: Huge Universe
Karma: 0
Member
Ilia, I found the relevant code:

$last_post = '';
if ($u->u_last_post_id) {
$r = db_saq('SELECT m.subject, m.id, m.post_stamp, t.forum_id FROM {SQL_TABLE_PREFIX}msg m INNER JOIN {SQL_TABLE_PREFIX}thread t ON m.thread_id=t.id WHERE m.id='.$u->u_last_post_id);
if ($usr->users_opt & 1048576 || !empty($frm_perms[$r[3]])) {
$last_post = '{TEMPLATE: last_post}';
}

But I'm sure what to change here. It looks like the query is already looking inside the message table ({SQL_TABLE_PREFIX}msg). Is the thread table ({SQL_TABLE_PREFIX}thread) the one with the old record? Should this table be removed from the query? By "looking directly inside the msg table", did you mean getting form_id from the msg table? Does the msg table have forum_id, or an equivalent field? I tried looking it up myself but didn't have access. Thanks!
Re: New members with old posts linked in profile [message #21292 is a reply to message #21290] Wed, 24 November 2004 18:41 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
The where condition of that query fetches a particular message who's id is know, this is something you cannot rely upon.

The query should be something like this:
"SELECT m.subject, m.id, m.post_stamp, t.forum_id 
FROM {SQL_TABLE_PREFIX}msg m
INNER JOIN {SQL_TABLE_PREFIX}thread t ON m.thread_id=t.id WHERE m.apr=1  AND m.poster_id=".$u->id."
ORDER BY m.post_stamp DESC LIMIT 1"


FUDforum Core Developer
Re: New members with old posts linked in profile [message #21293 is a reply to message #21292] Wed, 24 November 2004 18:44 Go to previous messageGo to next message
treebeard is currently offline  treebeard   United States
Messages: 44
Registered: April 2004
Location: Huge Universe
Karma: 0
Member
Thanks, Ilia! I'll give it a try (saving a backup of the file, of course). And I assume I should make this change in all shared forums.
Re: New members with old posts linked in profile [message #21296 is a reply to message #21293] Wed, 24 November 2004 18:53 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
yes.

FUDforum Core Developer
Re: New members with old posts linked in profile [message #21311 is a reply to message #21296] Wed, 24 November 2004 19:34 Go to previous messageGo to next message
treebeard is currently offline  treebeard   United States
Messages: 44
Registered: April 2004
Location: Huge Universe
Karma: 0
Member
One more note, Ilia. I effected the change, and it appears to work correctly (or nearly): there is no longer a bogus last message associated, which is what we want. However, a little glitch: when there is no last message in a given forum, what displays instead is this:

Last Message: Wed, 31 December 1969 19:00

Seems like it goes back to the system start date? I think this is better than linking the wrong message which happens to have the same ID, but someone born in 1975 may wonder why his last message was six years before he was born!

Re: New members with old posts linked in profile [message #21312 is a reply to message #21311] Wed, 24 November 2004 19:36 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Modify the
if ($usr->users_opt & 1048576 || !empty($frm_perms[$r[3]])) {
condition to be
if ($r && ($usr->users_opt & 1048576 || !empty($frm_perms[$r[3]]))) {


FUDforum Core Developer
Re: New members with old posts linked in profile [message #21313 is a reply to message #21312] Wed, 24 November 2004 19:47 Go to previous message
treebeard is currently offline  treebeard   United States
Messages: 44
Registered: April 2004
Location: Huge Universe
Karma: 0
Member
Cool! that took care of it.

thanks, Ilia.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Is the new flat "category" listing an option?
Next Topic: Custom Titles
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 00:59:51 GMT 2024

Total time taken to generate the page: 0.03306 seconds