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

Clean theme throws exception if set_pagelayout is called too late

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5.2
    • Fix Version/s: 2.5.2
    • Component/s: Themes
    • Labels:
    • Testing Instructions:
      Hide
      1. Comment out fix adding set_pagelayout() in line 36 in grade/edit/outcome/import.php
      2. Switch to Clean them
      3. Enable Outcomes (advanced features)
      4. Open course gradebook
      5. Select in dropdown 'Import outcomes'
      6. Make sure there are no errors on page but layout may look weird
      Show
      Comment out fix adding set_pagelayout() in line 36 in grade/edit/outcome/import.php Switch to Clean them Enable Outcomes (advanced features) Open course gradebook Select in dropdown 'Import outcomes' Make sure there are no errors on page but layout may look weird
    • Affected Branches:
      MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE
    • Pull Master Branch:
      MDL-42648_M26

      Description

      As found in MDL-40971 Clean theme throws an exception if $PAGE->set_pagelayout() is changed after output is initialised.

      Obviously in each particular case we should fix the call to set_pagelayout() like Mary did in MDL-40971.

      But in the generic case since we don't show any warnings (they are commented out) inside the set_pagelayout() function, theme should be more tolerant to it as well. Standard-like themes have some php code inside layout files checking if block regions are not empty:
      https://github.com/marinaglancy/moodle/blob/master/theme/base/layout/general.php#L6

      Bootstrapbase/clean should do something similar. AFAIK Sam Hemelryk was trying to avoid php code in layout files, maybe we can insert the check in renderer then?

      diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php
      index 56b6f56..5a0bf27 100644
      --- a/lib/outputrenderers.php
      +++ b/lib/outputrenderers.php
      @@ -3199,7 +3199,12 @@ EOD;
                   'data-blockregion' => $displayregion,
                   'data-droptarget' => '1'
               );
      -        return html_writer::tag($tag, $this->blocks_for_region($region), $attributes);
      +        if ($this->page->blocks->region_has_content($region, $this)) {
      +            $content = $this->blocks_for_region($region);
      +        } else {
      +            $content = '';
      +        }
      +        return html_writer::tag($tag, $content, $attributes);
           }
       
           /**
      

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  9/Sep/13