mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
MDL-41384 course: do not show debugging message if $COURSE contains format options
before showing debugging message make sure that field exists in database and not only in the object
This commit is contained in:
parent
e262d58d6c
commit
1c4b2c0b8d
2 changed files with 17 additions and 7 deletions
|
@ -45,8 +45,11 @@ if ($id) {
|
|||
print_error('cannoteditsiteform');
|
||||
}
|
||||
|
||||
$course = course_get_format($id)->get_course();
|
||||
// Login to the course and retrieve also all fields defined by course format.
|
||||
$course = get_course($id);
|
||||
require_login($course);
|
||||
$course = course_get_format($course)->get_course();
|
||||
|
||||
$category = $DB->get_record('course_categories', array('id'=>$course->category), '*', MUST_EXIST);
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
require_capability('moodle/course:update', $coursecontext);
|
||||
|
|
|
@ -237,14 +237,21 @@ abstract class format_base {
|
|||
if ($this->course === false) {
|
||||
$this->course = get_course($this->courseid);
|
||||
$options = $this->get_format_options();
|
||||
$dbcoursecolumns = null;
|
||||
foreach ($options as $optionname => $optionvalue) {
|
||||
if (!isset($this->course->$optionname)) {
|
||||
$this->course->$optionname = $optionvalue;
|
||||
} else {
|
||||
debugging('The option name '.$optionname.' in course format '.$this->format.
|
||||
' is invalid because the field with the same name exists in {course} table',
|
||||
DEBUG_DEVELOPER);
|
||||
if (isset($this->course->$optionname)) {
|
||||
// Course format options must not have the same names as existing columns in db table "course".
|
||||
if (!isset($dbcoursecolumns)) {
|
||||
$dbcoursecolumns = $DB->get_columns('course');
|
||||
}
|
||||
if (isset($dbcoursecolumns[$optionname])) {
|
||||
debugging('The option name '.$optionname.' in course format '.$this->format.
|
||||
' is invalid because the field with the same name exists in {course} table',
|
||||
DEBUG_DEVELOPER);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$this->course->$optionname = $optionvalue;
|
||||
}
|
||||
}
|
||||
return $this->course;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue