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

Cohort administration pages require, not require_once, /cohort/lib.php

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.11, 3.2.8, 3.3.5, 3.4.2, 3.5
    • Fix Version/s: 3.4.5, 3.5.2
    • Component/s: Cohorts
    • Labels:
    • Testing Instructions:
      Hide
      1. Add an include to /cohort/lib.php at the end of /config.php, after the require_once /lib/setup.php:  

        require_once(_DIR_. '/cohort/lib.php');

      • Verify that, with the patch missing, the cohort administration page does not load, yielding a white page or a fatal error depending on your debugging configuration.
      • Verify that, with the patch is applied, the cohort administration page loads.
      Show
      Add an include to /cohort/lib.php at the end of /config.php, after the require_once /lib/setup.php:   require_once(_DIR_. '/cohort/lib.php' ); Verify that, with the patch missing, the cohort administration page does not load, yielding a white page or a fatal error depending on your debugging configuration. Verify that, with the patch is applied, the cohort administration page loads.
    • Affected Branches:
      MOODLE_31_STABLE, MOODLE_32_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE
    • Fixed Branches:
      MOODLE_34_STABLE, MOODLE_35_STABLE
    • Pull 3.5 Branch:
    • Pull Master Branch:
      MDL-61238-master

      Description

      We've recently encountered an issue where cohort administration pages (both index.php and edit.php) serve up fatal errors to our LTs. This is caused by /cohort/lib.php being included twice, causing redeclaration of the functions.

      Note that this issue cannot be encountered on a stock Moodle instance, but with a customisation that includes /cohort/lib.php somewhere after the /lib/setup.php include. This can be simulated by adding the following line to the very bottom of /config.php, after the include:

      require_once "{$CFG->dirroot}/cohort/lib.php";
      

      Although not relevant, as an example of why a developer might wish to include the cohort library during initialisation: we use cohort memberships to target different branding configuration at our users. To achieve this we have a component that replaces the theme_config object on moodle_page with a branded variant.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  10/Sep/18

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 30 minutes
                  30m