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

Using the multimedia filter sets theme up for output..

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Do
    • 2.8.6, 2.9
    • None
    • Filters
    • MOODLE_28_STABLE, MOODLE_29_STABLE

    Description

      Its possible that you might want to filter some text (e.g. to send an email) before a moodle page has been setup for output. Unfortunately having the multimedia filter enabled causes problems in this case.

      Steps to reproduce

      1. Add this test.php file:

        <?php
        require('config.php');
         
        require_login();
        $PAGE->set_context(context_system::instance());
        $PAGE->set_url('/test.php');
        $course = get_course(2);
         
        // Imagine this is, say emailing a message when someone logs in or something..
        $msg = format_text('<a href="/test.php">test</a>', FORMAT_MOODLE, array('context' => context_course::instance($course->id), 'filter' => true));
         
        $PAGE->set_course($course);
         
        echo $OUTPUT->header('foo');
        echo $OUTPUT->footer();
        

        2. View the file output

      Expected result:
      It should be possible to filter text without it altering the current theme.

      Actual result

      Coding error detected, it must be fixed by a programmer: The theme has already been set up for this page ready for output. Therefore, you can no longer change the theme, or anything that might affect what the current theme is, for example, the course.
       
      More information about this error
       
      Debug info: Stack trace when the theme was set up: <ul style="text-align: left" data-rel="backtrace"><li>line 637 of /lib/pagelib.php: call to moodle_page->initialise_theme_and_output()</li><li>line 812 of /lib/pagelib.php: call to moodle_page->magic_get_theme()</li><li>line 64 of /filter/mediaplugin/filter.php: call to moodle_page->get_renderer()</li><li>line 167 of /lib/filterlib.php: call to filter_mediaplugin->filter()</li><li>line 205 of /lib/filterlib.php: call to filter_manager->apply_filter_chain()</li><li>line 337 of /lib/filterlib.php: call to filter_manager->filter_text()</li><li>line 1259 of /lib/weblib.php: call to performance_measuring_filter_manager->filter_text()</li><li>line 10 of /test.php: call to format_text()</li></ul>
      Error code: codingerror
      Stack trace:
      line 1837 of /lib/pagelib.php: coding_exception thrown
      line 914 of /lib/pagelib.php: call to moodle_page->ensure_theme_not_set()
      line 12 of /test.php: call to moodle_page->set_course()
      

      Further details
      You'll see a few more examples of this problem if you search the tracker, a good example is MDL-50271 which had to be fixed in hacky way, but I think it should be possible to filter texts without the entire theme setup.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              poltawski Dan Poltawski
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: