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

Inconsistent coursecontact checking can lead to PHP notices during plugin installation

XMLWordPrintable

    • MOODLE_400_STABLE
    • MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
    • MDL-78242-401
    • MDL-78242-402
    • Hide

      Simulate lack of configuration:

      1. Execute the following:

        $ php admin/cli/cfg.php --name=coursecontact --unset
        

      Manual test

      1. Log in as admin
      2. Navigate to Development > Debugging in site administration
        • Debug display: Developer
        • Display debug messages: Yes
      3. Navigate to Courses > Manage courses and categories in site administration
      4. Assign roles for the default category (via Permissions action)
      5. Select Manager role (or any other, doesn't matter)
      6. Add admin user to the manager role
      7. Confirm there are no PHP notices displayed on the page
      Show
      Simulate lack of configuration: Execute the following: $ php admin/cli/cfg.php --name=coursecontact --unset Manual test Log in as admin Navigate to Development > Debugging in site administration Debug display: Developer Display debug messages: Yes Navigate to Courses > Manage courses and categories in site administration Assign roles for the default category (via Permissions action) Select Manager role (or any other, doesn't matter) Add admin user to the manager role Confirm there are no PHP notices displayed on the page

      As happens in Workplace (WP-1932, WPQA-52) the following is observed during installation:

      ++ Success (0.05 seconds) ++
       
      -->tool_tenant
       
      Warning: Undefined property: stdClass::$coursecontact in /var/www/html/course/classes/category.php on line 906
      

      The line in question. We should be consistent with all other uses of this config property and avoid these PHP notices:

      $ git grep "if.*CFG\->coursecontact"
      course/classes/category.php:        if (!$CFG->coursecontact || !in_array($roleid, explode(',', $CFG->coursecontact))) {
      course/classes/category.php:        if (empty($courses) || empty($CFG->coursecontact)) {
      course/classes/list_element.php:        if (empty($CFG->coursecontact)) {
      enrol/self/lib.php:            if (!empty($CFG->coursecontact)) {
      lib/accesslib.php:    if (empty($CFG->coursecontact)) {
      

            pholden Paul Holden
            pholden Paul Holden
            Marina Glancy Marina Glancy
            David Carrillo David Carrillo
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 28 minutes
                1h 28m

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