diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 9ed46e3ae146d..bb9095354cada 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -3669,5 +3669,12 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2014060300.00); } + if ($oldversion < 2014061000.00) { + // Fixing possible wrong MIME type for Publisher files. + $filetypes = array('%.pub'=>'application/x-mspublisher'); + upgrade_mimetypes($filetypes); + upgrade_main_savepoint(true, 2014061000.00); + } + return true; } diff --git a/lib/db/upgradelib.php b/lib/db/upgradelib.php index 7e92a1ffeccea..a8dcb6b7ed2a5 100644 --- a/lib/db/upgradelib.php +++ b/lib/db/upgradelib.php @@ -456,3 +456,23 @@ function upgrade_availability_item($groupmembersonly, $groupingid, return null; } } + +/** + * 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) + ); + } +} \ No newline at end of file diff --git a/version.php b/version.php index 5f95af7544f13..08fa69ecf7ee9 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2014060500.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2014061000.00; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes.