Wrong database data in phpbb_users.user_lastpost_time ?

Get help with installation and running phpBB 3.2.x here. Please do not post bug reports, feature requests, or extension related questions here.
Post Reply
Registered User
Posts: 3
Joined: Fri Mar 29, 2019 7:32 pm

Wrong database data in phpbb_users.user_lastpost_time ?

Post by lays » Tue Jun 11, 2019 1:39 pm

What kind of data is kept in this field? I thought it is the time, when specific user wrote his last post but in my situation it is definitely not.

I have many users who have posted 10 posts after the time in user_lastpost_time.

User avatar
Registered User
Posts: 629
Joined: Wed Aug 15, 2018 3:23 am

Re: Wrong database data in phpbb_users.user_lastpost_time ?

Post by EA117 » Sun Jun 23, 2019 10:12 pm

Not a known issue that I've seen already referenced before, for what it's worth. To answer your question, the value being set in that database field is the current server UTC time as returned by the PHP time() function.

The code to update the user_lastpost_time seems to be there for both the "post" and "reply" cases of submit_post() in functions_posting.php, and is the same place that user_posts would be incremented, too. (Where the comment "// Update forum stats" appears in functions_posting.php.) There is a more simple update (less indirection involved) of user_lastpost_time from submit_pm() in functions_privmsgs.php as well.

You may already be fully aware, but the time stamp in user_lastpost_time is expected to be UTC, and not the user's or server's local time. Just in case that multi-hour difference between UTC versus the user's local time might explain the observations being made. Meaning the user expected they last posted at 22:00 but the database timestamp says 18:00; but a four hour difference there is actually the correct UTC offset for their 22:00 local posting time.

Based on code inspection I would not be immediately suspecting there is an issue there, at least not in current phpBB versions. Note there is an event (core.submit_post_modify_sql_data) which would permit an extension to have a say on what got written to the database, too. So if you suspect there is truly still an issue, eliminating any enabled extensions would be prudent to narrow down the source of the problem, too.

User avatar
Registered User
Posts: 5588
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン

Re: Wrong database data in phpbb_users.user_lastpost_time ?

Post by AmigoJack » Mon Jun 24, 2019 9:12 am

Execute this SQL query (i.e. thru phpMyAdmin) and report back and results:

Code: Select all

SELECT u.user_id
     , u.username
     , u.user_lastpost_time
     , from_unixtime( u.user_lastpost_time ) AS utc_user
     , p.post_time
     , from_unixtime( p.post_time ) AS utc_post
     , p.post_id
  FROM phpbb_users u
 INNER JOIN phpbb_posts p ON p.poster_id= u.user_id
 WHERE p.post_time> u.user_lastpost_time;
For me I had one result, where a user_lastpost_time corresponds to his post before his actual last post (example: user made only 3 posts ever, and user_lastpost_time was not assigned to the most recent post #3, but instead to post #2). And I also found out why: post #3 was not created by that user initially, but instead by someone else and then the post author was changed - in such a case the user_lastpost_time is out of sync.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
We will not come anybody anyway, nevertheless, it's best to shit this.

Post Reply

Return to “[3.2.x] Support Forum”