Commit e978112e authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1722132: Video mimetype not set correctly due to fetch by assoc

Rather than fetching by array now that we have multiple extensions
using the 'video/mp4' mimetype.

This would cause problems for older sites where the file was correctly
saved as 'video' artefacttype but where the fetching from db of the
mimetypes to compare would associate a different extension to
'video/mp4', eg 'm4v'.

This also meant that videos uploaded after commit
a5cf7d59

 could end up being saved as
atefacttype 'file' rather than 'video'

This patch fetches mimetypes as array and tidies things up for video

behatnotneeded

Change-Id: I53dc2d5ddb573d630f1de408cc9c027e488cd99e
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 3bf14023
......@@ -467,5 +467,21 @@ function xmldb_artefact_file_upgrade($oldversion=0) {
}
}
if ($oldversion < 2017100900) {
log_debug('Update video files that may have wrong artefacttype');
// For video/mp4 files added after commit a5cf7d59ebbd17193efaa38661eafe7b370095ee
// They can get wrong artefact filetype if last selected was not the one with 'mp4' description
$fromsql = " FROM (SELECT a.id FROM {artefact} a
JOIN {artefact_file_files} aff ON aff.artefact = a.id
WHERE aff.filetype = ?
AND a.artefacttype != ?) AS foo";
if (count_records_sql("SELECT COUNT(*) " . $fromsql, array('video/mp4', 'video'))) {
execute_sql("UPDATE {artefact} SET artefacttype = ?
WHERE id IN (
SELECT id " . $fromsql . "
)", array('video', 'video/mp4', 'video'));
}
}
return $status;
}
......@@ -247,7 +247,7 @@ class PluginArtefactFile extends PluginArtefact {
static $allmimetypes = null;
if (is_null($allmimetypes)) {
$allmimetypes = get_records_assoc('artefact_file_mime_types');
$allmimetypes = get_records_array('artefact_file_mime_types');
}
if (is_string($description)) {
......
......@@ -12,6 +12,6 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2016082901;
$config->release = '1.2.7';
$config->version = 2017100900;
$config->release = '1.2.8';
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment