dbnschools / moodle-theme_fordson

Theme for Moodle 3.3+
43 stars 40 forks source link

Missing null check in course.php line 84 #70

Closed martingreenaway closed 5 years ago

martingreenaway commented 5 years ago

Hi,

Firstly thanks for all the hard work on this theme which really helps to make Moodle a lot more presentable and usable. There is one error we are seeing in our implementation where we have not selected a Theme Preset. When using Configurable Reports, we're then seeing the following in our logs:

[Fri Mar 29 08:24:02.778060 2019] [php7:notice] [pid 11320] [client 158.255.12.25:63543] PHP Notice: Undefined property: stdClass::$preset in /var/www/moodle/theme/fordson/layout/course.php on line 84, referer: https://servername/blocks/configurable_reports/managereport.php

It seems to be because the following code in theme/fordson/layout/course.php makes an unsafe assumption that preset will always be set to a value:

if ($PAGE->theme->settings->preset != 'Spectrum-Achromatic') {
    $PAGE->requires->js('/theme/fordson/javascript/courseblock.js');
}

I've fixed it locally with an additional isset() condition in the if statement.

I can probably create a pull request for this if you'd like, although it may be easier for you to just splice it in?

if (isset($PAGE->theme->settings->preset) && $PAGE->theme->settings->preset != 'Spectrum-Achromatic') {
    $PAGE->requires->js('/theme/fordson/javascript/courseblock.js');
}

Regards, Martin

dbnschools commented 5 years ago

I've included this in the next release.