MDL-27756 Improving move_course() performance
This commit is contained in:
+3
-1
@@ -3370,10 +3370,13 @@ function move_courses($courseids, $categoryid) {
|
||||
}
|
||||
|
||||
$courseids = array_reverse($courseids);
|
||||
$newparent = get_context_instance(CONTEXT_COURSECAT, $category->id);
|
||||
$i = 1;
|
||||
|
||||
foreach ($courseids as $courseid) {
|
||||
if ($course = $DB->get_record('course', array('id'=>$courseid), 'id, category')) {
|
||||
$course = new stdClass();
|
||||
$course->id = $courseid;
|
||||
$course->category = $category->id;
|
||||
$course->sortorder = $category->sortorder + MAX_COURSES_IN_CATEGORY - $i++;
|
||||
if ($category->visible == 0) {
|
||||
@@ -3385,7 +3388,6 @@ function move_courses($courseids, $categoryid) {
|
||||
$DB->update_record('course', $course);
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$newparent = get_context_instance(CONTEXT_COURSECAT, $course->category);
|
||||
context_moved($context, $newparent);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user