diff --git a/course/edit.php b/course/edit.php index c549cc1..1fadcc5 100644 --- a/course/edit.php +++ b/course/edit.php @@ -145,7 +145,7 @@ if ($editform->is_cancelled()) { } } else { // Save any changes to the files used in the editor - update_course($data, $editoroptions); + update_course($data, $editoroptions,$categoryid!=$category->id); } // Redirect user to newly created/updated course. diff --git a/course/lib.php b/course/lib.php index 6ed5bb5..75ff3d6 100644 --- a/course/lib.php +++ b/course/lib.php @@ -2345,9 +2345,11 @@ function create_course($data, $editoroptions = NULL) { * * @param object $data - all the data needed for an entry in the 'course' table * @param array $editoroptions course description editor options + * @param boolean $update_sortorder set to false if the caller *knows* we have not changed + sort order, thus skipping expensive call to fix_course_sortorder() * @return void */ -function update_course($data, $editoroptions = NULL) { +function update_course($data, $editoroptions = NULL, $update_sortorder=true) { global $CFG, $DB; $data->timemodified = time(); @@ -2402,7 +2404,9 @@ function update_course($data, $editoroptions = NULL) { context_moved($context, $newparent); } - fix_course_sortorder(); + if($update_sortorder){ + fix_course_sortorder(); + } // purge appropriate caches in case fix_course_sortorder() did not change anything cache_helper::purge_by_event('changesincourse'); if ($changesincoursecat) {