MDL-41517 Do not call fix_course_sortorder unnecessarily
authorMarina Glancy <marina@moodle.com>
Tue, 3 Sep 2013 03:45:00 +0000 (13:45 +1000)
committerMarina Glancy <marina@moodle.com>
Tue, 3 Sep 2013 03:45:00 +0000 (13:45 +1000)
Thanks to Thomas Worthington

course/lib.php

index a0b5f5a..52462a2 100644 (file)
@@ -2408,7 +2408,10 @@ function update_course($data, $editoroptions = NULL) {
         $context->update_moved($newparent);
     }
 
-    fix_course_sortorder();
+    if ($movecat || (isset($data->sortorder) && $oldcourse->sortorder != $data->sortorder)) {
+        fix_course_sortorder();
+    }
+
     // purge appropriate caches in case fix_course_sortorder() did not change anything
     cache_helper::purge_by_event('changesincourse');
     if ($changesincoursecat) {