itamart / moodle-block_mhaairs

0 stars 5 forks source link

Incorrect call to $PAGE->url->compare without setting the $PAGE url in settings.php #3

Closed itamart closed 8 years ago

itamart commented 9 years ago

In settings.php there is a call to $PAGE->url->compare that serves as a condition to skip adding the 'available services' setting in any page that is not the admin/settings page of the block, in particular the admin/upgradesettings page that is loaded on install or upgrade. This is because on install the available service config setting would be displayed as a new setting but since there would not be any service the setting could not be set and the install would not be able to proceed.

However calling $PAGE->url->compare without setting the url first generates an error message when initializing the moodle server, e.g. on initialization of the phpunit testing environment.

A more appropriate way to achieve the same effect is by overriding the admin_setting_configmulticheckbox::get_setting() method in the specialized admin_setting_configmulticheckbox_mhaairs such that it returns array() rather than null if the setting is null (which would be the case when there are no choices). This would allow the install/upgrade to continue without trying to set the available services setting.