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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.5.5, 3.6, 3.7
    • Fix Version/s: 3.5.6, 3.6.4
    • Component/s: Backup, Logging
    • Labels:
    • Testing Instructions:
      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.
    • Affected Branches:
      MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE
    • Fixed Branches:
      MOODLE_35_STABLE, MOODLE_36_STABLE
    • Pull 3.5 Branch:
      MDL-65375-m35
    • Pull 3.6 Branch:
      MDL-65375-m36
    • Pull Master Branch:
      MDL-65375-master

      Description

      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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                quen Sam Marshall
                Reporter:
                stronk7 Eloy Lafuente (stronk7)
                Peer reviewer:
                Eloy Lafuente (stronk7)
                Integrator:
                Adrian Greeve
                Tester:
                Carlos Escobedo
                Participants:
                Component watchers:
                Adrian Greeve, Mihail Geshoski, Peter Dias, Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  13/May/19

                  Time Tracking

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