From 5fd16a3761e9c315e9900cf50912bb2f674a01bc Mon Sep 17 00:00:00 2001 From: Jason Fowler Date: Wed, 7 May 2014 13:38:46 +0800 Subject: [PATCH] MDL-45418 Files: Adding upgrade steps for publisher docs Conflicts: lib/db/upgrade.php lib/db/upgradelib.php version.php --- lib/db/upgrade.php | 7 +++++++ lib/db/upgradelib.php | 22 +++++++++++++++++++++- version.php | 2 +- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 00c7d651ef3..df8786ab514 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2984,5 +2984,12 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2013111803.01); } + if ($oldversion < 2013111803.05) { + // Fixing possible wrong MIME type for Publisher files. + $filetypes = array('%.pub'=>'application/x-mspublisher'); + upgrade_mimetypes($filetypes); + upgrade_main_savepoint(true, 2013111803.05); + } + return true; } diff --git a/lib/db/upgradelib.php b/lib/db/upgradelib.php index 31637f52d0b..ddb84a3e7ef 100644 --- a/lib/db/upgradelib.php +++ b/lib/db/upgradelib.php @@ -347,4 +347,24 @@ function upgrade_course_modules_sequences() { unset($sections); // Note that we don't need to reset course cache here because it is reset automatically after upgrade. -} \ No newline at end of file +} + +/** + * Updates the mime-types for files that exist in the database, based on their + * file extension. + * + * @param array $filetypes Array with file extension as the key, and mimetype as the value + */ +function upgrade_mimetypes($filetypes) { + global $DB; + $select = $DB->sql_like('filename', '?', false); + foreach ($filetypes as $extension=>$mimetype) { + $DB->set_field_select( + 'files', + 'mimetype', + $mimetype, + $select, + array($extension) + ); + } +} diff --git a/version.php b/version.php index fc7e2100956..545573be598 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2013111803.04; // 20131118 = branching date YYYYMMDD - do not modify! +$version = 2013111803.05; // 20131118 = branching date YYYYMMDD - do not modify! // RR = release increments - 00 in DEV branches. // .XX = incremental changes. -- 2.11.4.GIT