diff --git a/availability/classes/frontend.php b/availability/classes/frontend.php index b3b894c660476..8168b4c28f883 100644 --- a/availability/classes/frontend.php +++ b/availability/classes/frontend.php @@ -117,6 +117,11 @@ public static function include_all_javascript($course, ?\cm_info $cm = null, foreach ($enabled as $plugin => $info) { // Create plugin front-end object. $class = '\availability_' . $plugin . '\frontend'; + if (!class_exists($class)) { + continue; + } + + /** @var \core_availability\frontend $frontend */ $frontend = new $class(); // Add to array of required YUI modules. diff --git a/availability/classes/info.php b/availability/classes/info.php index a12307f18f560..5f3fdff380225 100644 --- a/availability/classes/info.php +++ b/availability/classes/info.php @@ -792,11 +792,10 @@ public static function completion_value_used($course, $cmid) { // plugin could also rely on the completion plugin. $pluginmanager = \core_plugin_manager::instance(); $enabled = $pluginmanager->get_enabled_plugins('availability'); - $componentparams = new \stdClass(); foreach ($enabled as $plugin => $info) { - // Use the static method. + /** @var \core_availability\condition $class */ $class = '\availability_' . $plugin . '\condition'; - if ($class::completion_value_used($course, $cmid)) { + if (class_exists($class) && $class::completion_value_used($course, $cmid)) { return true; } } diff --git a/availability/classes/tree.php b/availability/classes/tree.php index 36e759e763a55..1280ef2433075 100644 --- a/availability/classes/tree.php +++ b/availability/classes/tree.php @@ -220,9 +220,9 @@ public function __construct($structure, $lax = false, $root = true) { // First see if it's a condition. These have a defined type. if (isset($child->type)) { - // Look for a plugin of this type. + /** @var \core_availability\condition $classname */ $classname = '\availability_' . $child->type . '\condition'; - if (!array_key_exists($child->type, $enabled)) { + if (!array_key_exists($child->type, $enabled) || !class_exists($classname)) { if ($lax) { // On load of existing settings, ignore if class // doesn't exist.