Moodle
  1. Moodle
  2. MDL-37295

Old update post log rules are not parsed during restore

    Details

    • Testing Instructions:
      Hide

      This needs to be tested in all databases

      1. Goto a forum in a course
      2. update any two post
      3. Goto site admin>reports>live logs and make sure the log is in the format discuss.php?d=5565#p2&parent=19321
      4. Goto your database editor and edit one of these log entries and remove #p2 part only (mdl_logs)
      5. Backup the course with Include course logs checked
      6. Restore the course as new course on same site
      7. Make sure you get no errors during restore and the entries in the log report for this course are imported without any errors.
      Show
      This needs to be tested in all databases Goto a forum in a course update any two post Goto site admin>reports>live logs and make sure the log is in the format discuss.php?d=5565#p2&parent=19321 Goto your database editor and edit one of these log entries and remove #p2 part only (mdl_logs) Backup the course with Include course logs checked Restore the course as new course on same site Make sure you get no errors during restore and the entries in the log report for this course are imported without any errors.
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull 2.4 Branch:
      MDL-37295-m24
    • Pull Master Branch:
      MDL-37295-master
    • Rank:
      46898

      Description

      when restoring a course with forum activities + its user data in it with its
      user data. (via the Restore link, selecting the latest backup, including
      user data, excluding grade history). and this happen

      Starting restore
      Processing course.

      Error reading from database

      More information about this error
      Debug info: ERROR: invalid input syntax for integer: "5565&parent=19321"
      SELECT * FROM mdl_backup_ids_temp WHERE backupid = $1 AND itemname = $2 AND itemid = $3
      [array (
      0 => 'cadf23eacb4f9fc83b5e098cf57ae3a8',
      1 => 'forum_discussion',
      2 => '5565&parent=19321',
      )]
      Error code: dmlreadexception
      Stack trace:

      line 409 of /lib/dml/moodle_database.php: dml_read_exception thrown
      line 242 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
      line 720 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      line 1352 of /lib/dml/moodle_database.php: call to pgsql_native_moodle_database->get_records_sql()
      line 1324 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
      line 1303 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
      line 223 of /backup/util/dbops/restore_dbops.class.php: call to moodle_database->get_record()
      line 1521 of /backup/util/dbops/restore_dbops.class.php: call to restore_dbops::get_backup_ids_cached()
      line 197 of /backup/util/helper/restore_log_rule.class.php: call to restore_dbops::get_backup_ids_record()
      line 137 of /backup/util/helper/restore_log_rule.class.php: call to restore_log_rule->parse_tokens_and_matches()
      line 84 of /backup/util/helper/restore_logs_processor.class.php: call to restore_log_rule->process()
      line 2170 of /backup/moodle2/restore_stepslib.php: call to restore_logs_processor->process_log_record()
      line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_activity_logs_structure_step->process_log()
      line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()
      line 125 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk()
      line 91 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk()
      line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()
      line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk()
      line 169 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()
      line 253 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
      line ? of unknownfile: call to progressive_parser->end_tag()
      line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()
      line 137 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse()
      line 105 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process()
      line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
      line 194 of /backup/moodle2/restore_activity_task.class.php: call to base_task->execute()
      line 163 of /backup/util/plan/base_plan.class.php: call to restore_activity_task->execute()
      line 157 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
      line 315 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
      line 147 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
      line 59 of /backup/restore.php: call to restore_ui->execute()

        Issue Links

          Activity

          Hide
          Helen Foster added a comment -

          Raymond, thanks for your report with testing instructions (much appreciated) and patch. I've added Ankit as a watcher, since he fixed MDL-32104, and may wish to assign himself to this issue too.

          Show
          Helen Foster added a comment - Raymond, thanks for your report with testing instructions (much appreciated) and patch. I've added Ankit as a watcher, since he fixed MDL-32104 , and may wish to assign himself to this issue too.
          Hide
          Ankit Agarwal added a comment - - edited

          Hi Raymond,
          Thanks for your report.
          Am not sure how your url are in that format. normally it should be in the format
          http://ankit.moodle.local/stable/master/moodle/mod/forum/discuss.php?d=2#p4&parent=4

          The #p4 param is not present in url. Can you please look at the corresponding log url in your reports>log and confirm what is the url?

          The only possible explanation for this, that I can think of is the log entry being bit old, earlier from when the new format was introduced, Looking at the commit:-
          https://github.com/ankitagarwal/moodle/commit/cd4e6b1769dfe0399eeb29d13bb1030bd759172a

          If that is the case we should parse these old urls as well. Please confirm the url and if the log entry was generated before that commit was made i.e 2009

          Thanks

          Show
          Ankit Agarwal added a comment - - edited Hi Raymond, Thanks for your report. Am not sure how your url are in that format. normally it should be in the format http://ankit.moodle.local/stable/master/moodle/mod/forum/discuss.php?d=2#p4&parent=4 The #p4 param is not present in url. Can you please look at the corresponding log url in your reports>log and confirm what is the url? The only possible explanation for this, that I can think of is the log entry being bit old, earlier from when the new format was introduced, Looking at the commit:- https://github.com/ankitagarwal/moodle/commit/cd4e6b1769dfe0399eeb29d13bb1030bd759172a If that is the case we should parse these old urls as well. Please confirm the url and if the log entry was generated before that commit was made i.e 2009 Thanks
          Hide
          Raymond Antonio added a comment -

          Hi Ankit,

          Thank you for your comment. If I understood you right, I think you are correct this is my url format something like discuss.php?d=17&parent=20 and I added my patch above to Moodle integration master as I could reproduce the bug. Cheers Ankit

          Show
          Raymond Antonio added a comment - Hi Ankit, Thank you for your comment. If I understood you right, I think you are correct this is my url format something like discuss.php?d=17&parent=20 and I added my patch above to Moodle integration master as I could reproduce the bug. Cheers Ankit
          Hide
          Ankit Agarwal added a comment -

          Hi Raymond,
          If I understand your descriptions you are having issues with update post logs, but your patch is changing "view discussions" logs. And base on your last comment you said you are able to reproduce the error. Does this mean you are able to reproduce NEW log entries in the format you specified?

          I will work on a patch that will take care of old log entries, but I donot see any way of generating new log entries in that format.
          Thanks

          Show
          Ankit Agarwal added a comment - Hi Raymond, If I understand your descriptions you are having issues with update post logs, but your patch is changing "view discussions" logs. And base on your last comment you said you are able to reproduce the error. Does this mean you are able to reproduce NEW log entries in the format you specified? I will work on a patch that will take care of old log entries, but I donot see any way of generating new log entries in that format. Thanks
          Hide
          Ankit Agarwal added a comment -

          Submitting for review. will update stable patches after the review.
          Thanks

          Show
          Ankit Agarwal added a comment - Submitting for review. will update stable patches after the review. Thanks
          Hide
          Rossiani Wijaya added a comment -

          Hi Ankit,

          The patch looks great.

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

          +1 for integration.

          Show
          Rossiani Wijaya added a comment - Hi Ankit, The patch looks great. [y] Syntax [y] Output [y] Whitespace [-] Language [-] Databases [y] Testing - mysql only [-] Security [-] Documentation [y] Git [y] Sanity check +1 for integration.
          Hide
          Eloy Lafuente (stronk7) added a comment - - edited

          Plz, amend the issue title if needed (for what I read, the error reported by Raymond is about 'forum_discussion').

          Also, clarify the target branches, all the stable ones? Or that "new" format of the 'forum_discussion' logs where added recently?

          TIA and ciao!

          PS: Edited, "TIA and thanks" is a bit redundant, lol.

          Show
          Eloy Lafuente (stronk7) added a comment - - edited Plz, amend the issue title if needed (for what I read, the error reported by Raymond is about 'forum_discussion'). Also, clarify the target branches, all the stable ones? Or that "new" format of the 'forum_discussion' logs where added recently? TIA and ciao! PS: Edited, "TIA and thanks" is a bit redundant, lol.
          Hide
          Ankit Agarwal added a comment -

          Hi Eloy,
          Yeah I will update the stable branches before I push this for integration,
          The new format was added around three years ago as mentioned in my previous comments.

          Will update the title.
          Thanks

          Show
          Ankit Agarwal added a comment - Hi Eloy, Yeah I will update the stable branches before I push this for integration, The new format was added around three years ago as mentioned in my previous comments. Will update the title. Thanks
          Hide
          Ankit Agarwal added a comment -

          updated everything.
          Submitting for integration
          Thanks

          Show
          Ankit Agarwal added a comment - updated everything. Submitting for integration Thanks
          Hide
          Dan Poltawski added a comment -

          The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

          TIA and ciao

          Show
          Dan Poltawski added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
          Hide
          Sam Hemelryk added a comment -

          Thanks Raj, this has been integrated now.

          Show
          Sam Hemelryk added a comment - Thanks Raj, this has been integrated now.
          Hide
          Michael de Raadt added a comment -

          Test result: Success!

          Tested in MySQL in 2.3, 2.4 and Master.

          Also tested in PostgreSQL, MSSQL and Oracle in Master only.

          Show
          Michael de Raadt added a comment - Test result: Success! Tested in MySQL in 2.3, 2.4 and Master. Also tested in PostgreSQL, MSSQL and Oracle in Master only.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Surely you will be happy to know that your code is now part of Moodle upstream. Thanks, thanks!

          Closing as fixed, ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Surely you will be happy to know that your code is now part of Moodle upstream. Thanks, thanks! Closing as fixed, ciao

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: