Merge branch 'wip-MDL-41337-m25' of git://github.com/marinaglancy/moodle into MOODLE_25_STABLE

This commit is contained in:
Damyon Wiese
2013-10-30 10:53:52 +08:00
3 changed files with 37 additions and 2 deletions
+35
View File
@@ -2206,5 +2206,40 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2013051402.06);
}
if ($oldversion < 2013051402.10) {
// Find all fileareas that have missing root folder entry and add the root folder entry.
if (empty($CFG->filesrootrecordsfixed)) {
$sql = "SELECT distinct f1.contextid, f1.component, f1.filearea, f1.itemid
FROM {files} f1 left JOIN {files} f2
ON f1.contextid = f2.contextid
AND f1.component = f2.component
AND f1.filearea = f2.filearea
AND f1.itemid = f2.itemid
AND f2.filename = '.'
AND f2.filepath = '/'
WHERE (f1.component <> 'user' or f1.filearea <> 'draft')
and f2.id is null";
$rs = $DB->get_recordset_sql($sql);
$defaults = array('filepath' => '/',
'filename' => '.',
'userid' => $USER->id,
'filesize' => 0,
'timecreated' => time(),
'timemodified' => time(),
'contenthash' => sha1(''));
foreach ($rs as $r) {
$pathhash = sha1("/$r->contextid/$r->component/$r->filearea/$r->itemid".'/.');
$DB->insert_record('files', (array)$r + $defaults +
array('pathnamehash' => $pathhash));
}
$rs->close();
// To skip running the same script on the upgrade to the next major release.
set_config('filesrootrecordsfixed', 1);
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2013051402.10);
}
return true;
}
+1 -1
View File
@@ -807,7 +807,7 @@ function file_save_draft_area_files($draftitemid, $contextid, $component, $filea
$newhashes = array();
$filecount = 0;
foreach ($draftfiles as $file) {
if (!$options['subdirs'] && ($file->get_filepath() !== '/' or $file->is_directory())) {
if (!$options['subdirs'] && $file->get_filepath() !== '/') {
continue;
}
if (!$allowreferences && $file->is_external_file()) {
+1 -1
View File
@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2013051402.09; // 20130514 = branching date YYYYMMDD - do not modify!
$version = 2013051402.10; // 20130514 = branching date YYYYMMDD - do not modify!
// RR = release increments - 00 in DEV branches
// .XX = incremental changes