Skip to content

Commit

Permalink
MDL-78632 filetypes: Introduce yaml file type
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusboon committed Jul 28, 2023
1 parent a1d5d1b commit c22f82d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/classes/filetypes.php
Expand Up @@ -313,6 +313,9 @@ protected static function get_default_types() {
'xml' => array('type' => 'application/xml', 'icon' => 'markup'),
'xsl' => array('type' => 'text/xml', 'icon' => 'markup'),

'yaml' => array('type' => 'application/yaml', 'icon' => 'markup'),
'yml' => array('type' => 'application/yaml', 'icon' => 'markup'),

'zip' => array('type' => 'application/zip', 'icon' => 'archive', 'groups' => array('archive'), 'string' => 'archive')
);
}
Expand Down
22 changes: 22 additions & 0 deletions lib/db/upgrade.php
Expand Up @@ -3348,5 +3348,27 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2023062900.01);
}

if ($oldversion < 2023072500.00) {
// Upgrade yaml mime type for existing yaml and yml files.
$filetypes = array(
'%.yaml' => 'application/yaml',
'%.yml' => 'application/yaml,'
);

$select = $DB->sql_like('filename', '?', false);
foreach ($filetypes as $extension => $mimetype) {
$DB->set_field_select(
'files',
'mimetype',
$mimetype,
$select,
array($extension)
);
}

// Main savepoint reached.
upgrade_main_savepoint(true, 2023072500.00);
}

return true;
}

0 comments on commit c22f82d

Please sign in to comment.