MDL-56653 enrol_meta: a single DB query in edit_instance_validation
authorVitaly <potenkov@gmail.com>
Fri, 18 Sep 2020 18:45:26 +0000 (21:45 +0300)
committerSimey Lameze <simey@moodle.com>
Wed, 18 Nov 2020 07:05:42 +0000 (15:05 +0800)
commit3a2d8a175ec7d7b82a93c067ef80c0caf0311732
tree5318517b920c54ea2b753778ae261c0c5bcaea04
parent15b4174a9fe4bfdcb39705bf373c0d39cd0cbb3e
MDL-56653 enrol_meta: a single DB query in edit_instance_validation

The 'edit_instance_validation()' method checks for existing meta enrolment instances.
The fix replaces DB queries in a loop for each course with a single query for all courses.
Also, a new testing method 'test_edit_instance_validation_with_existing_courses()'
was added to /enrol/meta/tests/plugin_test.php to test if the new implementation
returns an error in case of trying to save the already linked courses in the 'customint1' field.
enrol/meta/lib.php
enrol/meta/tests/plugin_test.php