Skip to:
Content
Pages
Categories
Search
Top
Bottom

whos online widget not working (think it\'s a mysql timezone problem)

  • Avatar of francescolaffi
    francescolaffi
    Participant

    @francescolaffi

    Tried the online widget and it don’t show any user also if there is someone else online. Using wpmu 2.9.1.1 and bp 1.2.1.

    I’ve looked into it a little and found that a user is selected as online if is last activity not more than 5 min before than mysql time, as you can see in this line from bp-core-classes

    if ( 'active' == $type || 'online' == $type )
    $sql['where_active'] = "AND um.meta_key = 'last_activity'";
    if ( 'online' == $type )
    $sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= NOW()";

    I’ve looked in the db and tried some queries, i think the problem is that the last_activity is UTC and NOW() is UTC+1.

    If I mod the core to check 65 MINUTE it works, but this is only a temporary solution and only valid for this configuration.

    Maybe there’s a stupid solution or setting I haven’t found, but please help me find it. I’m on shared hosting so i can’t change the mysql server clock or timezone.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Avatar of francescolaffi
    francescolaffi
    Participant

    @francescolaffi

    maybe I found a better solution

    If I’m right bp always set last_activity meta in gmt ( bp_core_record_activity() in bp-core.php use gmdate ) so the query should compare with that timezone, I tried using UTC_TIMESTAMP() instead of NOW() in the query and it’s working.

    If some expert can confirm that this solution is valide not only for my configuration but for everyone I’ll open a ticket.

    Thanks

    Avatar of nickrita
    nickrita
    Participant

    @nickrita

    frances, where exactly did you do the change? If you could tell me php and line, I can try out if it works for me, too.

    Avatar of gasparking
    gasparking
    Participant

    @gasparking

    @nickrita

    in ” bp-core/bp-core-classes.php” around line 139

    change “NOW()” to “UTC_TIMESTAMP()”

    Don’t know if it’s a good solution but it works

    Avatar of jesperpopma
    Jesper
    Participant

    @jesperpopma

    @gasparking,

    Thanks for the info, but as you mentioned maybe not the best solution. What about updates?

    Could this be called from a bp-custom.php? And if so how?

    Or is this bug fixed in the next BP version?

    Thanks!

    Avatar of francescolaffi
    francescolaffi
    Participant

    @francescolaffi

    I forgot to add this topic to my favorites so I didn’t read your replies.

    I opened a ticked in the trac http://trac.buddypress.org/ticket/2271 , if this solution is working for you could write there that you successfully tested and solution will be probably included in future bp release. You can login in the trac with the same account you are using for this forum.

    Avatar of ericreynolds007
    ericreynolds007
    Participant

    @ericreynolds007

    Revising the bp-core/bp-core-classes.php from “NOW()” to “UTC_TIMESTAMP()” worked like a charm!

    Thank you gasparking

    Avatar of nickrita
    nickrita
    Participant

    @nickrita

    It worked for me, too! Thank you very much!

    Avatar of Andy Peatling
    Andy Peatling
    Keymaster

    @apeatling

    Thanks, this is fixed in the 1.2 branch and will be in the next release.

    Avatar of thomasgoh
    thomasgoh
    Member

    @thomasgoh

    Using bp1.2.3 and wp2.9.2 and got the same problem too.

    Tried the solution stated here and it woks!

    Many thanks :)

    Avatar of liveview
    liveview
    Member

    @liveview

    Same, 1.2.2, didn’t work until I did this. Works perfectly now tho :D

    Avatar of samudradaka
    samudradaka
    Participant

    @samudradaka

    I had the same problem and the UTC_TIMESTAMP() fix worked for me too. Be great to have this added to the next BP version

    Avatar of Andy Peatling
    Andy Peatling
    Keymaster

    @apeatling

    Already fixed in the 1.2 branch, it will be in the next version.

Viewing 12 replies - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.