From d217b9506835d7244b69858e848ef4ffb3afe378 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Tue, 26 Oct 2010 19:14:22 +0000 Subject: [PATCH] MDL-22584 detect file paths that are too long to fit into 255 char db field --- lib/db/upgradelib.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/db/upgradelib.php b/lib/db/upgradelib.php index da8d78b4240..17ac87d1c5c 100644 --- a/lib/db/upgradelib.php +++ b/lib/db/upgradelib.php @@ -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());