Merge branch 'w31_MDL-40898_m26_openhandles' of https://github.com/skodak/moodle

This commit is contained in:
Dan Poltawski 2013-07-30 14:06:04 +08:00
commit 857e3ecb6c
3 changed files with 10 additions and 0 deletions

View File

@ -715,6 +715,7 @@ class tool_uploadcourse_course {
$this->error('errorwhilerestoringcourse', new lang_string('errorwhilerestoringthecourse', 'tool_uploadcourse'));
}
$rc->destroy();
unset($rc); // File logging is a mess, we can only try to rely on gc to close handles.
}
// Proceed with enrolment data.

View File

@ -44,6 +44,13 @@ class tool_uploadcourse_helper {
*/
public static function clean_restore_content() {
global $CFG;
// There are some sloppy unclosed file handles in backup/restore code,
// let's hope somebody unset all controllers before calling this
// and destroy magic will close all remaining open file handles,
// otherwise Windows will fail deleting the directory.
gc_collect_cycles();
if (!empty($CFG->keeptempdirectoriesonbackup)) {
$cache = cache::make('tool_uploadcourse', 'helper');
$backupids = (array) $cache->get('backupids');

View File

@ -129,6 +129,7 @@ class tool_uploadcourse_helper_testcase extends advanced_testcase {
$this->assertTrue(isset($result['backup_destination']));
$c1backupfile = $result['backup_destination']->copy_content_to_temp();
$bc->destroy();
unset($bc); // File logging is a mess, we can only try to rely on gc to close handles.
// Creating backup file.
$bc = new backup_controller(backup::TYPE_1COURSE, $c2->id, backup::FORMAT_MOODLE,
@ -138,6 +139,7 @@ class tool_uploadcourse_helper_testcase extends advanced_testcase {
$this->assertTrue(isset($result['backup_destination']));
$c2backupfile = $result['backup_destination']->copy_content_to_temp();
$bc->destroy();
unset($bc); // File logging is a mess, we can only try to rely on gc to close handles.
// Checking restore dir.
$dir = tool_uploadcourse_helper::get_restore_content_dir($c1backupfile, null);