Moodle
  1. Moodle
  2. MDL-33815

Users stuck in Online Users block

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.3, 2.2.5
    • Fix Version/s: 2.2.6, 2.3.3
    • Component/s: Blocks
    • Labels:
    • Testing Instructions:
      Hide
      1. As Admin, enable "Online user" block on a course and frontpage
      2. Enrol a student to the course
      3. check that user is display online online within the block (course and frontpage)

      In frontpage:

      1. Access the user table in DB and change the student lastaccess field to the past (eg: 1149936122)
      2. Refresh the page and make sure student name is not display within the block
      3. Access the user table in DB and change the student lastaccess field to the future (eg: 3349936122)
      4. Refresh the page and make sure student name is not display within the block

      In a course page:

      1. Access the user_lastaccess table in DB and change the student timeaccess field to the past (eg: 1149936122)
      2. Refresh the page and make sure student name is not display within the block
      3. Access the user_lastaccess table in DB and change the student timeaccess field to the future (eg: 3349936122)
      4. Refresh the page and make sure student name is not display within the block

      Make sure there's no error display on the page.

      Show
      As Admin, enable "Online user" block on a course and frontpage Enrol a student to the course check that user is display online online within the block (course and frontpage) In frontpage: Access the user table in DB and change the student lastaccess field to the past (eg: 1149936122) Refresh the page and make sure student name is not display within the block Access the user table in DB and change the student lastaccess field to the future (eg: 3349936122) Refresh the page and make sure student name is not display within the block In a course page: Access the user_lastaccess table in DB and change the student timeaccess field to the past (eg: 1149936122) Refresh the page and make sure student name is not display within the block Access the user_lastaccess table in DB and change the student timeaccess field to the future (eg: 3349936122) Refresh the page and make sure student name is not display within the block Make sure there's no error display on the page.
    • Affected Branches:
      MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      41901

      Description

      If there are users in the database that have an invalid lastaccess, lastlogin or currentlogin timestamp in the mdl_user table, or have an invalid record in the mdl_user_lastaccess they will be stuck in the Online block, even if they are deleted.

      Fix: add "AND deleted = 0" to line 61 and 84 in /block/online_users/block_online_users.php

        Activity

        Hide
        Michael de Raadt added a comment -

        "It's a trap!". (Let me out of here!)

        Thanks for reporting that and providing a solution. Perhaps it's also worth checking that the time range is less than now.

        Show
        Michael de Raadt added a comment - "It's a trap!". (Let me out of here!) Thanks for reporting that and providing a solution. Perhaps it's also worth checking that the time range is less than now.
        Hide
        Mary Cooch added a comment -

        Interesting..I wonder if this is what happened to these guys who have been stuck in the Moodle lounge for over a week? http://moodle.org/mod/forum/discuss.php?d=208486

        Show
        Mary Cooch added a comment - Interesting..I wonder if this is what happened to these guys who have been stuck in the Moodle lounge for over a week? http://moodle.org/mod/forum/discuss.php?d=208486
        Hide
        David Bezemer added a comment -

        As far as I can see this behaviour happens when the users existed in a very old version of Moodle, and were deleted there.
        From what I could see their timestamps are set to a number somewhere in 2038 or so.

        One of the setups I noticed this with was an environment that started at Moodle 1.8 and was subsequently upgraded to Moodle 2.
        So a complete fix for the problem would include an upgrade check for invalid timestamps (> NOW) and correct them, for instance to NOW

        Show
        David Bezemer added a comment - As far as I can see this behaviour happens when the users existed in a very old version of Moodle, and were deleted there. From what I could see their timestamps are set to a number somewhere in 2038 or so. One of the setups I noticed this with was an environment that started at Moodle 1.8 and was subsequently upgraded to Moodle 2. So a complete fix for the problem would include an upgrade check for invalid timestamps (> NOW) and correct them, for instance to NOW
        Hide
        Rossiani Wijaya added a comment -

        Hi David,

        Thank you for providing solution for the issue.

        I'm not convince to update the timestamps to now within the upgrade. I think the issue might occurs during the process of backup/restore/converting process from 1.8 to 2.x.

        Therefore, I'm only fixing the 'online_user' block display.

        Sending for peer-review.

        Show
        Rossiani Wijaya added a comment - Hi David, Thank you for providing solution for the issue. I'm not convince to update the timestamps to now within the upgrade. I think the issue might occurs during the process of backup/restore/converting process from 1.8 to 2.x. Therefore, I'm only fixing the 'online_user' block display. Sending for peer-review.
        Hide
        Ankit Agarwal added a comment -

        Hi Rosie,

        Patch looks good to me.

        [Y] Syntax
        [Y] Output
        [Y] Whitespace
        [-] Language
        [y] Databases
        [Y] Testing
        [-] Security
        [-] Documentation
        [Y] Git
        [Y] Sanity check

        Thanks

        Show
        Ankit Agarwal added a comment - Hi Rosie, Patch looks good to me. [Y] Syntax [Y] Output [Y] Whitespace [-] Language [y] Databases [Y] Testing [-] Security [-] Documentation [Y] Git [Y] Sanity check Thanks
        Hide
        Rossiani Wijaya added a comment -

        Thanks Ankit for reviewing.

        Submitting for integration review.

        Show
        Rossiani Wijaya added a comment - Thanks Ankit for reviewing. Submitting for integration review.
        Hide
        Dan Poltawski added a comment -

        Integrated thanks Rosie.

        TO TESTER: Please be sure to test this in the different scenarios in the testing instructions, different code paths are followed and its very important we ensure this is all covered.

        Show
        Dan Poltawski added a comment - Integrated thanks Rosie. TO TESTER: Please be sure to test this in the different scenarios in the testing instructions, different code paths are followed and its very important we ensure this is all covered.
        Hide
        David Monllaó added a comment -

        It passes, tested in 22 and master

        Show
        David Monllaó added a comment - It passes, tested in 22 and master
        Hide
        Aparup Banerjee added a comment -

        Your issue has dug up some gold.
        It works great i've been told.
        Go forth, be brave, be bold.

        yay! "All your thoughts are belong to everyone."

        Thanks and ciao!

        Show
        Aparup Banerjee added a comment - Your issue has dug up some gold. It works great i've been told. Go forth, be brave, be bold. yay! "All your thoughts are belong to everyone." Thanks and ciao!

          People

          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: