Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-32233 core_course_duplicate_course: Fixed integrator review detai…

  • Loading branch information...
commit 6c7d3e3100f515317d6fbe410e5498e411d5780f 1 parent 9aa84e9
Juan Leyva jleyva authored

Showing 1 changed file with 14 additions and 5 deletions. Show diff stats Hide diff stats

  1. +14 5 course/externallib.php
19 course/externallib.php
@@ -805,15 +805,20 @@ public static function duplicate_course($courseid, $fullname, $shortname, $categ
805 805
806 806 $bc->execute_plan();
807 807 $results = $bc->get_results();
808   - $file = $results['backup_destination'];
  808 +
  809 + if (!empty($results['backup_destination'])) {
  810 + $file = $results['backup_destination'];
  811 + } else {
  812 + $file = null;
  813 + }
  814 +
809 815 $bc->destroy();
810 816
811 817 // Restore the backup immediately.
812 818
813   - // In a backup mode different than import, we need to unzip the file because the backup temp directory is deleted.
814   - if (!empty($backupsettings['users'])) {
815   - check_dir_exists($CFG->tempdir . '/backup');
816   - $file->extract_to_pathname(get_file_packer(), $CFG->tempdir . '/backup/' . $backupid);
  819 + // Check if we need to unzip the file because the backup temp dir does not contains backup files.
  820 + if ($file and !file_exists($backupbasepath . "/moodle_backup.xml")) {
  821 + $file->extract_to_pathname(get_file_packer(), $backupbasepath);
817 822 }
818 823
819 824 // Create new course.
@@ -867,6 +872,10 @@ public static function duplicate_course($courseid, $fullname, $shortname, $categ
867 872 fulldelete($backupbasepath);
868 873 }
869 874
  875 + if ($file) {
  876 + $file->delete();
  877 + }
  878 +
870 879 return array('id' => $course->id, 'shortname' => $course->shortname);
871 880 }
872 881

0 comments on commit 6c7d3e3

Please sign in to comment.
Something went wrong with that request. Please try again.