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

Debugging message shown when restoring a backup into a category with an image in the description

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1, 3.1.3
    • Fix Version/s: 3.1.4
    • Component/s: Backup
    • Labels:
    • Testing Instructions:
      Hide
      1. Log in as the admin.
      2. Create a new category with an image in the description.
      3. Add a course to this category.
      4. Create a backup of the course and download it.
      5. Go to 'Site administration' > 'Courses' > 'Manage courses and categories'.
      6. Under the settings for the new category click on 'Restore course'.
      7. Select the backup you downloaded earlier and click 'Restore'.
      8. On the next page click 'Continue'.
      9. Confirm on the page where you are deciding to restore it as a new course or existing course there is no debugging message and you can see the image in the category description.
      10. Complete the restoration and ensure it works as expected.
      Show
      Log in as the admin. Create a new category with an image in the description. Add a course to this category. Create a backup of the course and download it. Go to 'Site administration' > 'Courses' > 'Manage courses and categories'. Under the settings for the new category click on 'Restore course'. Select the backup you downloaded earlier and click 'Restore'. On the next page click 'Continue'. Confirm on the page where you are deciding to restore it as a new course or existing course there is no debugging message and you can see the image in the category description. Complete the restoration and ensure it works as expected.
    • Affected Branches:
      MOODLE_31_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-57169_master

      Description

      Steps (with debug active):

      1. Insert an image in category description
      2. Start a restore by course backup
      3. The debug error message is displayed

      =========================================================
      Before calling format_text(), the content must be processed with file_rewrite_pluginfile_urls()
      line 1313 of /lib/weblib.php: call to debugging()
      line 746 of /backup/util/ui/renderer.php: call to format_text()
      line 319 of /lib/outputrenderers.php: call to core_backup_renderer->render_restore_category_search()
      line 283 of /backup/util/ui/renderer.php: call to plugin_renderer_base->render()
      line 535 of /backup/util/ui/restore_ui_stage.class.php: call to core_backup_renderer->course_selector()
      line 129 of /backup/restore.php: call to restore_ui_stage_destination->display()
      =========================================================

      In order to fix it:
      In file /backup/util/ui/renderer.php change the next lines (method render_restore_category_search):

                      $row->cells = array(
                          html_writer::empty_tag('input', array('type' => 'radio', 'name' => 'targetid', 'value' => $category->id)),
                          format_string($category->name, true, array('context' => context_coursecat::instance($category->id))),
                          format_text($category->description, $category->descriptionformat, array('overflowdiv' => true))
                      );
      

      By:

                      $context = context_coursecat::instance($category->id);
                      $row->cells = array(
                          html_writer::empty_tag('input', array('type' => 'radio', 'name' => 'targetid', 'value' => $category->id)),
                          format_string($category->name, true, array('context' => context_coursecat::instance($category->id))),
                          format_text(file_rewrite_pluginfile_urls($category->description, 'pluginfile.php', $context->id, 'coursecat', 'description', null), $category->descriptionformat, array('overflowdiv' => true))
                      );
      

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                9/Jan/17