Moodle
  1. Moodle
  2. MDL-18351

activity block should detect no course and return.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.4, 2.0
    • Fix Version/s: 1.9.5, 2.0
    • Component/s: Blocks
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE, MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE, MOODLE_20_STABLE
    • Rank:
      31507

      Description

      Somehow this block managed to get on the admin pagetype for a site I'm helping with and it caused rebuild_course_cache to get rebuilt for the entire site... 24,000 queries!

      this teeny patch fixes it:

      diff --git a/blocks/activity_modules/block_activity_modules.php b/blocks/activity_modules/block_activity_modules.php
      index 14e9239..9f4e5f7 100644
      — a/blocks/activity_modules/block_activity_modules.php
      +++ b/blocks/activity_modules/block_activity_modules.php
      @@ -24,6 +24,9 @@ class block_activity_modules extends block_list

      { $course = get_record('course', 'id', $this->instance->pageid); }

      + if (empty($course))

      { + return ''; + }

      require_once($CFG->dirroot.'/course/lib.php');

      $modinfo = get_fast_modinfo($course);

      which I will commit to head & stable if nobody stops me

        Activity

          People

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

            Dates

            • Created:
              Updated:
              Resolved: