From aeda42f7d6d95a3cc8fd82002b8d9a4c790dfcae Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Fri, 13 Aug 2010 07:41:34 +0000 Subject: [PATCH] MDL-23792 fixing upgrade problem with missing pictures in mod/database --- mod/data/db/upgrade.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mod/data/db/upgrade.php b/mod/data/db/upgrade.php index ecc4080ab19..9f216a5b997 100644 --- a/mod/data/db/upgrade.php +++ b/mod/data/db/upgrade.php @@ -123,9 +123,11 @@ function xmldb_data_upgrade($oldversion) { if ($content->type == 'picture') { // migrate thumb $filepath = "$CFG->dataroot/$content->course/$CFG->moddata/data/$content->dataid/$content->fieldid/$content->recordid/thumb/$content->content"; - if (!$fs->file_exists($context->id, 'mod_data', $filearea, $content->id, '/', 'thumb_'.$filename)) { - $file_record['filename'] = 'thumb_'.$file_record['filename']; - $fs->create_file_from_pathname($file_record, $filepath); + if (file_exists($filepath)) { + if (!$fs->file_exists($context->id, 'mod_data', $filearea, $content->id, '/', 'thumb_'.$filename)) { + $file_record['filename'] = 'thumb_'.$file_record['filename']; + $fs->create_file_from_pathname($file_record, $filepath); + } unlink($filepath); } }