MDL-22584 detect file paths that are too long to fit into 255 char db field
This commit is contained in:
@@ -287,6 +287,8 @@ function upgrade_migrate_files_course($context, $path, $delete) {
|
||||
$items = new DirectoryIterator($fullpathname);
|
||||
$fs = get_file_storage();
|
||||
|
||||
$textlib = textlib_get_instance();
|
||||
|
||||
foreach ($items as $item) {
|
||||
if ($item->isDot()) {
|
||||
continue;
|
||||
@@ -323,6 +325,11 @@ function upgrade_migrate_files_course($context, $path, $delete) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($textlib->strlen($filepath) > 255) {
|
||||
echo $OUTPUT->notification(" File path longer than 255 chars, skipping: ".$fullpathname.$item->getFilename());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$fs->file_exists($context->id, $component, $filearea, '0', $filepath, $filename)) {
|
||||
$file_record = array('contextid'=>$context->id, 'component'=>$component, 'filearea'=>$filearea, 'itemid'=>0, 'filepath'=>$filepath, 'filename'=>$filename,
|
||||
'timecreated'=>$item->getCTime(), 'timemodified'=>$item->getMTime());
|
||||
|
||||
Reference in New Issue
Block a user