XF 2.0 Increase Online status timeout

Hi guys, first post so go gentle, I've ported over from VB and am just having a little trouble increasing this option above the limited 60 minutes.

I found online how you do it on older version but not on ZF2?

Any help appreciated.

Matt
 
If you want to do this without editing any code you can do it via the inspect console.

 
@imno007

PHP:
class SessionActivity extends Repository
{
    public function getOnlineCounts($onlineCutOff = null)
    {
        if ($onlineCutOff === null)
        {
            $onlineCutOff = \XF::$time - $this->options()->onlineStatusTimeout * 43200;
        }

        return $this->db()->fetchRow("
            SELECT
                SUM(IF(user_id >= 0 AND robot_key = '', 1, 0)) AS total,
                SUM(IF(user_id > 0, 1, 0)) AS members,
                SUM(IF(user_id = 0 AND robot_key = '', 1, 0)) AS members
            FROM xf_session_activity
            WHERE view_date >= ?
        ", $onlineCutOff);
    }

I set as 43200 minute at above.

PHP:
public function pruneExpiredActivityRecords($cutOff = null)
    {
        if ($cutOff === null)
        {
            $expiration = $this->getDefaultSessionActivityExpiration();
            if (!$expiration)
            {
                return;
            }

            $cutOff = \XF::$time - $expiration;
        }

        $this->db()->delete('xf_session_activity', 'view_date < ?', $cutOff);
    }

How should I update here?


You'll have to update the value in the final line:


public function pruneExpiredActivityRecords($cutOff = null)
{
if ($cutOff === null)
{
$cutOff = \XF::$time - 86400; (seconds to hours= 24 hours)
 
For whatever reason, you still can't do this with XF's default settings. You'll have to edit src/XF/Repository/SessionActivity.php, look for this line and change the value there:

$cutOff = \XF::$time - 3600;

You might also have to put the forum in dev mode and edit the value in your admin - I can't remember offhand if this is really necessary, but just in case. (Or maybe you could just do that and not actually have to edit the sessions file.) You'll get an error every time XF does a file health check, but you can ignore it.

I changed this line. What do I have to do now? Just activate dev mode? How do I do this exactly?

Thanks in advance.

Best regards,
Chris
 
Ok, I already figured it out myself and the changes worked.

Add the following line to config.php:

Code:
$config['development']['enabled'] = true;
Should I remove/delete the line with Dev mode activated after changing the online-status-session?
 
I changed this line. What do I have to do now? Just activate dev mode? How do I do this exactly?

Thanks in advance.

Best regards,
Chris

Ok, I already figured it out myself and the changes worked.

Add the following line to config.php:

Code:
$config['development']['enabled'] = true;
Should I remove/delete the line with Dev mode activated after changing the online-status-session?
Since I made the changes, I have received the following error message in the ACP:

Code:
Check completed on 4,939 files. The files listed below have contents different from those originally downloaded.

If you have edited these files yourself, you may ignore this message, otherwise you should investigate further as this may be evidence of corrupted or altered files.
XenForo
src/XF/Repository/SessionActivity.php Unexpected contents

What could that be about?

Best regards,
Chris
 
~~~ contents different from those originally downloaded.
If you have edited these files yourself, you may ignore this message, otherwise you should investigate further as this may be evidence of corrupted or altered files.
XenForo
src/XF/Repository/SessionActivity.php Unexpected contents
You changed a core XF file. It's an alert.
 
Hi Brogan...oops...I mean Paul B! ;)

That means this error message will remain as long as I keep this change...but it won't have any negative impact?!

OK! You Got Me! I am convinced and, above all, can I be reassured? ^^

Best regards,
Chris
 
I know. That's what this thread is about and many others have done it before me.

Just apparently without getting this error?!

Maybe this has something to do with the latest version?
If it really annoys you the hash must be regenerated.
 
I guess we have to make the same changes at SessionActivityRepository.php for XF2.3. However, the online members widget is disappearing once we uploaded the amended SessionActivityRepository.php

Is there anything else we should do for 2.3?
 
I guess we have to make the same changes at SessionActivityRepository.php for XF2.3. However, the online members widget is disappearing once we uploaded the amended SessionActivityRepository.php

Is there anything else we should do for 2.3?

SUM(IF(user_id >= 0 AND robot_key = '', 1, 0)) AS guests

This line should remain the same. If we change as members, then the online members widget will disappear.
 
SUM(IF(user_id >= 0 AND robot_key = '', 1, 0)) AS guests

This line should remain the same. If we change as members, then the online members widget will disappear.
Yeah, I think I experienced that as well at one point, while experimenting with this and that. I just wanted to get the guests count set to zero, but couldn't figure out at the time how to do it without it messing up the total member count, so ended up just leaving it alone. Better to have a bunch of bots as "guests," I guess. I'll eventually get back around to taking another look at it, but it's not the end of the world.
 
Last edited:
Back
Top Bottom