Commit 4441d5e5 authored by David Mudrák's avatar David Mudrák
Browse files

MDL-49329 admin: Fix report on required core version in missing plugins

If the plugin was missing from disk, the required core version was
displayed as "Moodle {$a}" because the core dependency resolver always
returns an object.
parent 35f2b674
......@@ -794,6 +794,11 @@ class core_plugin_manager {
public function resolve_requirements(\core\plugininfo\base $plugin, $moodleversion=null, $moodlebranch=null) {
global $CFG;
if ($plugin->versiondisk === null) {
// Missing from disk, we have no version.php to read from.
return array();
}
if ($moodleversion === null) {
$moodleversion = $CFG->version;
}
......
......@@ -350,6 +350,7 @@ class core_plugin_manager_testcase extends advanced_testcase {
// Prepare a fake pluginfo instance.
$pluginfo = testable_plugininfo_base::fake_plugin_instance('fake', '/dev/null', 'one', '/dev/null/fake',
'testable_plugininfo_base', $pluginman);
$pluginfo->versiondisk = 2015060600;
// Test no $plugin->requires is specified in version.php.
$pluginfo->versionrequires = null;
......@@ -409,6 +410,12 @@ class core_plugin_manager_testcase extends advanced_testcase {
$pluginfo->dependencies = array('foo_bar' => 2025010100);
$reqs = $pluginman->resolve_requirements($pluginfo, 2015110900, 30);
$this->assertEquals($pluginman::REQUIREMENT_UNAVAILABLE, $reqs['foo_bar']->availability);
// Plugin missing from disk - no version.php available.
$pluginfo = testable_plugininfo_base::fake_plugin_instance('fake', '/dev/null', 'missing', '/dev/null/fake',
'testable_plugininfo_base', $pluginman);
$pluginfo->versiondisk = null;
$this->assertEmpty($pluginman->resolve_requirements($pluginfo, 2015110900, 30));
}
public function test_missing_dependencies() {
......@@ -416,8 +423,11 @@ class core_plugin_manager_testcase extends advanced_testcase {
$one = testable_plugininfo_base::fake_plugin_instance('fake', '/dev/null', 'one', '/dev/null/fake',
'testable_plugininfo_base', $pluginman);
$one->versiondisk = 2015070800;
$two = testable_plugininfo_base::fake_plugin_instance('fake', '/dev/null', 'two', '/dev/null/fake',
'testable_plugininfo_base', $pluginman);
$two->versiondisk = 2015070900;
$pluginman->inject_testable_plugininfo('fake', 'one', $one);
$pluginman->inject_testable_plugininfo('fake', 'two', $two);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment