Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-71835

Log report error when retrieving user fullname from DB

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.11
    • 3.10.7, 3.11.3
    • Reports
    • MOODLE_311_STABLE
    • MOODLE_310_STABLE, MOODLE_311_STABLE
    • MDL-71835-311
    • Hide

      Ensure you have two browser windows open (one in private mode so you can login twice to the same site)

      In order to simulate the actions necessary to trigger this in real life (read logs; populate users; read logs again - this time with new users compared to the first read) - add a sleep() call around line 532 of report/log/classes/table_log.php so it looks like the following:

              // Update list of users which will be displayed on log page.
              $this->update_users_used();
              sleep(10); // Add this line.
      

      Browser one

      1. Log in as admin
      2. Create a new user
      3. Navigate to Reports > Logs in site administration
      4. Change All days to Today and All activities to View
      5. Press Get these logs
      6. Quickly switch to browser two

      Browser two

      1. Log in as new user
      2. Switch back to browser one

      Browser one

      1. Once report reloads (after 10 second sleep)
      2. Confirm there is no PHP notice about undefined offset
      3. Confirm the User full name column displays the name of the new user for their login/dashboard viewed events
      Show
      Ensure you have two browser windows open (one in private mode so you can login twice to the same site) In order to simulate the actions necessary to trigger this in real life (read logs; populate users; read logs again - this time with new users compared to the first read) - add a sleep() call around line 532 of report/log/classes/table_log.php so it looks like the following: // Update list of users which will be displayed on log page. $this->update_users_used(); sleep(10); // Add this line. Browser one Log in as admin Create a new user Navigate to Reports > Logs in site administration Change All days to Today and All activities to View Press Get these logs Quickly switch to browser two Browser two Log in as new user Switch back to browser one Browser one Once report reloads (after 10 second sleep) Confirm there is no PHP notice about undefined offset Confirm the User full name column displays the name of the new user for their login/dashboard viewed events

    Description

      The log report contains code to try to account for logs containing users who weren't present the first time the logreader was used to select log records (MDL-48595)

      It's hard to hit in practice, except on very high traffic sites with lots of consistent log data, but easy to replicate by patching locally to simulate the same

      The // We already looked for the user and it does not exist. line doesn't account for users who we haven't previously looked for at all, and generates the following PHP notice:

      Notice: Undefined offset: 6 in /opt/moodle/master/src/report/log/classes/table_log.php on line 122
      

      The subsequent code for requesting the user object from the database doesn't make much sense either as $DB->get_records_sql returns an array, which means the fullname column of such rows contain just a dash instead of the expected users fullname:

      Attachments

        Activity

          People

            pholden Paul Holden
            pholden Paul Holden
            Sujith Haridasan Sujith Haridasan
            Victor Déniz Falcón Victor Déniz Falcón
            Angelia Dela Cruz Angelia Dela Cruz
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              13/Sep/21

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 45 minutes
                1h 45m