Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-31175 backup: Fixed undefined in register_dependency

  • Loading branch information...
commit 61e14418d0214376386857229421c234df266b41 1 parent c91704e
@samhemelryk samhemelryk authored
View
2  backup/util/settings/base_setting.class.php
@@ -294,7 +294,7 @@ public function register_dependency(setting_dependency $dependency) {
if ($this->is_circular_reference($dependency->get_dependent_setting())) {
$a = new stdclass();
$a->alreadydependent = $this->name;
- $a->main = $dependentsetting->get_name();
+ $a->main = $dependency->get_dependent_setting()->get_name();
throw new base_setting_exception('setting_circular_reference', $a);
}
$this->dependencies[$dependency->get_dependent_setting()->get_name()] = $dependency;
View
17 backup/util/settings/simpletest/testsettings.php
@@ -32,10 +32,12 @@
require_once($CFG->dirroot . '/backup/backup.class.php');
require_once($CFG->dirroot . '/backup/util/settings/base_setting.class.php');
require_once($CFG->dirroot . '/backup/util/settings/backup_setting.class.php');
+require_once($CFG->dirroot . '/backup/util/settings/setting_dependency.class.php');
require_once($CFG->dirroot . '/backup/util/settings/root/root_backup_setting.class.php');
require_once($CFG->dirroot . '/backup/util/settings/activity/activity_backup_setting.class.php');
require_once($CFG->dirroot . '/backup/util/settings/section/section_backup_setting.class.php');
require_once($CFG->dirroot . '/backup/util/settings/course/course_backup_setting.class.php');
+require_once($CFG->dirroot . '/backup/util/ui/backup_ui_setting.class.php');
/*
* setting tests (all)
@@ -209,6 +211,21 @@ function test_base_setting() {
$this->assertEqual($e->a->alreadydependent, 'test4');
}
+ $bs1 = new mock_base_setting('test1', base_setting::IS_INTEGER, null);
+ $bs2 = new mock_base_setting('test2', base_setting::IS_INTEGER, null);
+ $bs1->register_dependency(new setting_dependency_disabledif_empty($bs1, $bs2));
+ try {
+ // $bs1 is already dependent on $bs2 so this should fail.
+ $bs2->register_dependency(new setting_dependency_disabledif_empty($bs2, $bs1));
+ $this->assertTrue(false, 'base_setting_exception expected');
+ } catch (exception $e) {
+ $this->assertTrue($e instanceof base_setting_exception);
+ $this->assertEqual($e->errorcode, 'setting_circular_reference');
+ $this->assertTrue($e->a instanceof stdclass);
+ $this->assertEqual($e->a->main, 'test1');
+ $this->assertEqual($e->a->alreadydependent, 'test2');
+ }
+
// Create 3 settings and observe between them, last one must
// automatically inherit all the settings defined in the main one
$bs1 = new mock_base_setting('test1', base_setting::IS_INTEGER, null);
Please sign in to comment.
Something went wrong with that request. Please try again.