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

Call to format_text during course cache building causes debugging message

XMLWordPrintable

    • MOODLE_26_STABLE, MOODLE_30_STABLE, MOODLE_31_STABLE, MOODLE_32_STABLE
    • MOODLE_31_STABLE, MOODLE_32_STABLE
    • wip-MDL-41809-master
    • Hide
      1. Enable developer debugging mode
      2. Create a course with a graded activity
      3. Add another activity with access restriction that depends on grade in the first activity
      4. Copy URL of the second activity
      5. Try to open this URL as a student who does not satisfy grade condition, you should be redirected to course page
      6. In CLI purge caches
      7. Try to open the same URL again as a student, you should be redirected to course page without debugging notices
      Show
      Enable developer debugging mode Create a course with a graded activity Add another activity with access restriction that depends on grade in the first activity Copy URL of the second activity Try to open this URL as a student who does not satisfy grade condition, you should be redirected to course page In CLI purge caches Try to open the same URL again as a student, you should be redirected to course page without debugging notices

      Rewriting the issue description after investigation:
      grade_item->get_name() in conditionlib returns the name that has already been formatted and passed through get_string(). The item name is cached in course modinfo/sectioninfo if there is some module or section with availability depending on the grade in this item.
      This was discovered via the debugging message if format_string() is called before page context was set (see below), but it also means that get_string and format_string are called for language, user and context that were used when cache was build and not when the string was displayed. This may cause problems in multilang environment and comprehensive filters that depend on particular course.

      Example: with multilang filter enabled, cache was rebuild when english-speaking teacher was accessing the course. The English name of the activity will be displayed to French-speaking student.

      ---------------
      Original description:

      It seems that something has been recently broken:

      1) master branch (I've not tried stables)
      2) Go to ANY activity (DEBUG_DEVELOPER enabled). I've tried glossary, forum, lesson.
      3) Purge caches
      4) After the redirect, this is shown:

      Coding problem: $PAGE->context was not set. You may have forgotten to call require_login() or $PAGE->set_context(). The page may not display correctly as a result
      line 451 of /lib/pagelib.php: call to debugging()
      line 734 of /lib/pagelib.php: call to moodle_page->magic_get_context()
      line 1342 of /lib/weblib.php: call to moodle_page->__get()
      line 1223 of /lib/grade/grade_item.php: call to format_string()
      line 575 of /lib/conditionlib.php: call to grade_item->get_name()
      line 525 of /lib/conditionlib.php: call to condition_info_base::get_grade_name()
      line 131 of /lib/conditionlib.php: call to condition_info_base::fill_availability_conditions_inner()
      line 1064 of /course/lib.php: call to condition_info::fill_availability_conditions()
      line 617 of /lib/modinfolib.php: call to get_array_of_activities()
      line 450 of /lib/modinfolib.php: call to course_modinfo::build_course_cache()
      line 411 of /lib/modinfolib.php: call to course_modinfo->__construct()
      line 2003 of /lib/modinfolib.php: call to course_modinfo::instance()
      line 2837 of /lib/moodlelib.php: call to get_fast_modinfo()
      line 42 of /mod/lesson/view.php: call to require_login()
      

      Weird, because it is require_login() the function being executed.

      Ciao

            marina Marina Glancy
            stronk7 Eloy Lafuente (stronk7)
            Ankit Agarwal Ankit Agarwal
            Andrew Lyons Andrew Lyons
            Marcus Green Marcus Green
            Votes:
            6 Vote for this issue
            Watchers:
            15 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.