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

Malformed urls in logs of forum "update post" events causes failure when restoring backups

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Development in progress
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.1
    • Fix Version/s: STABLE backlog
    • Component/s: Forum
    • Labels:
    • Database:
      PostgreSQL, Oracle
    • Affected Branches:
      MOODLE_21_STABLE

      Description

      mod/forum/post.php is generating "update post" log entries with a 'url' value that is invalid, for example: discuss.php?d=132#p481&parent=481

      This is fatal when restoring a backup of a forum activity (for example, the attached backup), including full log information, on a database that does not implicitly discard non-integer characters at the end of an integer value. The process fails with this exception:

      Debug info: ERROR: invalid input syntax for integer: "132#p481"
      SELECT * FROM mdl_backup_ids_temp WHERE backupid = $1 AND itemname = $2 AND itemid = $3
      [array (
      0 => '4ad689e593b2e32dfe33db3dd39b9e05',
      1 => 'forum_discussion',
      2 => '132#p481',
      )]
      Stack trace:
       
          line 394 of /lib/dml/moodle_database.php: dml_read_exception thrown
          line 232 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
          line 678 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
          line 1307 of /lib/dml/moodle_database.php: call to pgsql_native_moodle_database->get_records_sql()
          line 1279 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
          line 1259 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
          line 1269 of /backup/util/dbops/restore_dbops.class.php: call to moodle_database->get_record()
          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 1879 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 179 of /backup/moodle2/restore_activity_task.class.php: call to base_task->execute()
          line 148 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 310 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
          line 144 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
          line 46 of /backup/restore.php: call to restore_ui->execute()

      The attached patch corrects the creation of these malformed log entries and also handles existing backups that were created containing these broken log entries.

      To reproduce the problematic log entries:

      1. post in a forum as a regular student
      2. edit the posting as a teacher and save the change
      3. observe in the log a "forum update post" entry with a malformed URL

      To reproduce the restore error:

      1. back up the forum created above with full log data and user data
      2. restore the backup including the log data and user data
      3. observe the failure

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              jonof Jonathon Fowler
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated: