On my test site, it seems that the first time I log in a user they appear in the "Who's Online" block and stay there. Even though the number of authenticated users goes down when one logs off, their name still appears on the list. The listing is only correct when all users log off and no list is displayed at all.

I will look at the code the first chance I get.

Comments

davemicc’s picture

Status: Active » Needs review
StatusFileSize
new1.36 KB

I found the problem.

The way the code was doing it was by finding the timestamp of the beginning of the period a user had to have accessed something to count them online. Then, it treated this timestamp like the number of seconds users would be counted online. Essentially, all users that had accessed something since 1970 must've been counted online.

This patch seems to fix the problem.

davemicc’s picture

StatusFileSize
new1.41 KB

The block still sometimes contradicts itself. If a user logs out of an authenticated session they will still display on the "online users" list for another 15 minutes.

If we change the code to use an inner join against the sessions table when we select the recently active users from the users table I think we can achieve better results. I don't know how much slower this query is.

davemicc’s picture

StatusFileSize
new1.41 KB

Added table specification to ORDER BY clause in query.

Gurpartap Singh’s picture

Version: x.y.z » 5.x-dev
Status: Needs review » Fixed

This seems already fixed in Drupal 5.x HEAD version. Not sure this kind of update will go into Drupal 4.7.x branch.

davemicc’s picture

Yes, it seems to have been fixed in issue #93042. Almost the same as my last patch except their code is supposed to be a little faster.

Anonymous’s picture

Status: Fixed » Closed (fixed)