Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-27756 Improving move_course() performance

  • Loading branch information...
commit 77bf97e300a1335e18159bbe24d40cd7dd23f02d 1 parent ecb8829
@marinaglancy marinaglancy authored
Showing with 3 additions and 1 deletion.
  1. +3 −1 course/lib.php
View
4 course/lib.php
@@ -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);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.