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

Restore of logs need to support the new jsonformat setting + null bug fix

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.5.6, 3.6.4
    • 3.5.5, 3.6, 3.7
    • Backup, Logging
    • MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE
    • MOODLE_35_STABLE, MOODLE_36_STABLE
    • MDL-65375-master
    • Hide

      Setup

      • Create a new test course (it should have the default Announcements forum).
      • Enrol a test account as a student on that course
      • Ensure that both standard and database logging are enabled, both with the 'jsonformat' option OFF.

      Testing (Moodle 3.7)

      1. Log in as the test student.
      2. View the test course (note: this action has empty 'other' variable).
      3. Go into the Announcement forum.
      4. Type 'frog' into the 'Search forums' box and click to search forums. There won't be any results, but this action has an 'other' variable set.
      5. Log back in as admin.
      6. Backup the test course, including users (default) and logs (not default).
      7. Restore to a new course, including users and logs.
      8. Perform the next checks for BOTH logstores (standard and database):
        • Use the log report to look at the logs for today, for the test student. You should see the events (course view, forum view, forum search) as in the original course.
        • Check in the databases using a query like this (fill in the course and user numerical ids): SELECT eventname, other FROM mdl_logstore_standard_log WHERE courseid=??? AND userid=???.
          • Expected: The 'other' values should contain data in PHP serialised format, such as 'N;' and 'a:1: {s:10:"searchterm";s:4:"frog";}

            '

      9. Go back to the logging settings and turn ON the jsonformat option in both stores.
      10. Restore the original course backup again, to a new course, including users and logs.
      11. Perform the next checks for BOTH logstores (standard and database):
        • Use the log report to look at the logs for today, for the test student. You should see the events (course view, forum view, forum search) as in the original course.
        • Check in the databases using a query like this (fill in the course and user numerical ids): SELECT eventname, other FROM mdl_logstore_standard_log WHERE courseid=??? AND userid=???.
          • Expected: The 'other' values should contain data in JSON format, such as 'null' (this is a string not a database null) and ' {"searchterm":"frog"}

            '.

      12. Now back up this new course (the one that contains data in JSON format), including users and logs.
      13. Go back to logging settings and turn OFF the jsonformat option in both stores.
      14. Restore the newest backup, to a new course, including users and logs.
      15. Perform the next checks for BOTH logstores (standard and database):
        • Use the log report to look at the logs for today, for the test student. You should see the events (course view, forum view, forum search) as in the original course.
        • Check in the databases using a query like this (fill in the course and user numerical ids): SELECT eventname, other FROM mdl_logstore_standard_log WHERE courseid=??? AND userid=???.
          • Expected: The 'other' values should contain data in PHP serialised format, such as 'N;' and 'a:1: {s:10:"searchterm";s:4:"frog";}

            '

      Testing (Moodle 3.6/3.5)

      1. As admin, go to the logging settings. Select 'standard logging'.
      2. Log in as the test student.
      3. View the test course (note: this action has empty 'other' variable).
      4. Go into the Announcement forum.
      5. Type 'frog' into the 'Search forums' box and click to search forums. There won't be any results, but this action has an 'other' variable set.
      6. Log back in as admin.
      7. Backup the test course, including users and logs.
      8. Restore to a new course, including users and logs.
      9. Check in the database using a query like this (fill in the course and user numerical ids): SELECT eventname, other FROM mdl_logstore_standard_log WHERE courseid=??? AND userid=???
        • Expected: The 'other' values should contain data in PHP serialised format, such as 'N;' and 'a:1: {s:10:"searchterm";s:4:"frog";}

          '. Note that the empty value is stored as 'N;' rather than a literal database null; this is now consistent with behaviour when logs are originally recorded.

      Show
      Setup Create a new test course (it should have the default Announcements forum). Enrol a test account as a student on that course Ensure that both standard and database logging are enabled, both with the 'jsonformat' option OFF. Testing (Moodle 3.7) Log in as the test student. View the test course (note: this action has empty 'other' variable). Go into the Announcement forum. Type 'frog' into the 'Search forums' box and click to search forums. There won't be any results, but this action has an 'other' variable set. Log back in as admin. Backup the test course, including users (default) and logs (not default). Restore to a new course, including users and logs. Perform the next checks for BOTH logstores (standard and database): Use the log report to look at the logs for today, for the test student. You should see the events (course view, forum view, forum search) as in the original course. Check in the databases using a query like this (fill in the course and user numerical ids): SELECT eventname, other FROM mdl_logstore_standard_log WHERE courseid=??? AND userid=???. Expected: The 'other' values should contain data in PHP serialised format, such as 'N;' and 'a:1: {s:10:"searchterm";s:4:"frog";} ' Go back to the logging settings and turn ON the jsonformat option in both stores. Restore the original course backup again, to a new course, including users and logs. Perform the next checks for BOTH logstores (standard and database): Use the log report to look at the logs for today, for the test student. You should see the events (course view, forum view, forum search) as in the original course. Check in the databases using a query like this (fill in the course and user numerical ids): SELECT eventname, other FROM mdl_logstore_standard_log WHERE courseid=??? AND userid=???. Expected: The 'other' values should contain data in JSON format, such as 'null' (this is a string not a database null) and ' {"searchterm":"frog"} '. Now back up this new course (the one that contains data in JSON format), including users and logs. Go back to logging settings and turn OFF the jsonformat option in both stores. Restore the newest backup, to a new course, including users and logs. Perform the next checks for BOTH logstores (standard and database): Use the log report to look at the logs for today, for the test student. You should see the events (course view, forum view, forum search) as in the original course. Check in the databases using a query like this (fill in the course and user numerical ids): SELECT eventname, other FROM mdl_logstore_standard_log WHERE courseid=??? AND userid=???. Expected: The 'other' values should contain data in PHP serialised format, such as 'N;' and 'a:1: {s:10:"searchterm";s:4:"frog";} ' Testing (Moodle 3.6/3.5) As admin, go to the logging settings. Select 'standard logging'. Log in as the test student. View the test course (note: this action has empty 'other' variable). Go into the Announcement forum. Type 'frog' into the 'Search forums' box and click to search forums. There won't be any results, but this action has an 'other' variable set. Log back in as admin. Backup the test course, including users and logs. Restore to a new course, including users and logs. Check in the database using a query like this (fill in the course and user numerical ids): SELECT eventname, other FROM mdl_logstore_standard_log WHERE courseid=??? AND userid=??? Expected: The 'other' values should contain data in PHP serialised format, such as 'N;' and 'a:1: {s:10:"searchterm";s:4:"frog";} '. Note that the empty value is stored as 'N;' rather than a literal database null; this is now consistent with behaviour when logs are originally recorded.

      This is a followup of MDL-62907, where a new jsonformat setting was introduced, allowing logs->info to be stored in other formats.

      Also, it was detected that empty infos are not encoded back ever, leading to empties/nulls in the database. This is a buf and should be fixed over all versions.

      So this issues will:

      1) Ensure that the restore process observe the jsonformat setting (master only).
      2) Ensure that empty values are also encoded before inserting to DB (stables & master)

      This may affect both standard and database logging.

      Ciao

            quen Sam Marshall
            stronk7 Eloy Lafuente (stronk7)
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Adrian Greeve Adrian Greeve
            Carlos Escobedo Carlos Escobedo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 5 hours, 5 minutes
                5h 5m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.