Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: 2.5.3, 2.6
-
Component/s: Files API, Installation
-
Testing Instructions:
- Run unit tests on all databases.
-
Affected Branches:MOODLE_25_STABLE, MOODLE_26_STABLE
-
Fixed Branches:MOODLE_25_STABLE, MOODLE_26_STABLE
-
Pull from Repository:
-
Pull Master Branch:
MDL-42882-master -
Pull Master Diff URL:
-
Story Points:20
-
Sprint:BACKEND Sprint 10
Description
In the update process for version 2013051402.10 there is a fix for missing root folder entries. (File: lib/db/upgrade.php line 2216)
To find the fileareas where these entries are missing a left join is used.
We have some installations with really large files table (more then 600 MB).
On these installations the update fails at this point.
Here is my attempt to get this work. Maybe it helps other people with the same problem.
if ($oldversion < 2013051402.10) {
|
|
$sql = "SELECT distinct f1.contextid, f1.component, f1.filearea, f1.itemid
|
FROM {files} f1
|
WHERE f1.component <> 'user' or f1.filearea <> 'draft'";
|
|
$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) {
|
// Is there a root folder entry for that filearea?
|
$count = $DB->count_records('files', array(
|
'contextid' => $r->contextid,
|
'component' => $r->component,
|
'filearea' => $r->filearea,
|
'itemid' => $r->itemid,
|
'filename' => '.',
|
'filepath' => '/'
|
));
|
if ($count) {
|
continue;
|
}
|
|
// There is no root folder entry for that filearea.
|
$pathhash = sha1("/$r->contextid/$r->component/$r->filearea/$r->itemid".'/.');
|
$DB->insert_record('files', (array)$r + $defaults +
|
array('pathnamehash' => $pathhash));
|
}
|
$rs->close();
|
// Main savepoint reached.
|
upgrade_main_savepoint(true, 2013051402.10);
|
}
|