diff --git a/admin/tool/filetypes/tests/tool_filetypes_test.php b/admin/tool/filetypes/tests/tool_filetypes_test.php index 6d536835d4e..1e22a01d4f9 100644 --- a/admin/tool/filetypes/tests/tool_filetypes_test.php +++ b/admin/tool/filetypes/tests/tool_filetypes_test.php @@ -14,16 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. -/** - * Unit tests for the custom file types. - * - * @package tool_filetypes - * @copyright 2014 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - use tool_filetypes\utils; /** @@ -32,10 +22,13 @@ use tool_filetypes\utils; * @package tool_filetypes * @copyright 2014 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \tool_filetypes\utils */ class tool_filetypes_test extends advanced_testcase { /** * Tests is_extension_invalid() function. + * + * @covers ::is_extension_invalid */ public function test_is_extension_invalid() { // The pdf file extension already exists in default moodle minetypes. @@ -56,6 +49,8 @@ class tool_filetypes_test extends advanced_testcase { /** * Tests is_defaulticon_allowed() function. + * + * @covers ::is_defaulticon_allowed */ public function test_is_defaulticon_allowed() { // You ARE allowed to set a default icon for a MIME type that hasn't @@ -73,6 +68,8 @@ class tool_filetypes_test extends advanced_testcase { /** * Tests get_icons_from_path() function. + * + * @covers ::get_icons_from_path */ public function test_get_icons_from_path() { // Get icons from the fixtures folder. @@ -83,4 +80,14 @@ class tool_filetypes_test extends advanced_testcase { // returned and only one of it. $this->assertEquals(array('frog' => 'frog', 'zombie' => 'zombie'), $icons); } + + /** + * Test get_file_icons() function to confirm no file icons are removed/added by mistake. + * + * @covers ::get_file_icons + */ + public function test_get_file_icons() { + $icons = utils::get_file_icons(); + $this->assertCount(30, $icons); + } } diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index d605b442eb7..ffc4baecee5 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -3429,5 +3429,47 @@ privatefiles,moodle|/user/files.php'; upgrade_main_savepoint(true, 2023082200.01); } + if ($oldversion < 2023082200.02) { + // Some MIME icons have been removed. They need to be replaced to 'unknown' for custom MIME types. + $removedicons = array_flip([ + 'clip-353', + 'edit', + 'env', + 'explore', + 'folder-open', + 'help', + 'move', + 'parent', + ]); + + $custom = []; + if (!empty($CFG->customfiletypes)) { + if (array_key_exists('customfiletypes', $CFG->config_php_settings)) { + // It's set in config.php, so the MIME icons can't be upgraded automatically. + echo("\nYou need to manually check customfiletypes in config.php because some MIME icons have been removed!\n"); + } else { + // It's a JSON string in the config table. + $custom = json_decode($CFG->customfiletypes); + } + } + + $changed = false; + foreach ($custom as $customentry) { + if (!empty($customentry->icon) && array_key_exists($customentry->icon, $removedicons)) { + // The icon has been removed, so set it to unknown. + $customentry->icon = 'unknown'; + $changed = true; + } + } + + if ($changed) { + // Save the new customfiletypes. + set_config('customfiletypes', json_encode($custom)); + } + + // Main savepoint reached. + upgrade_main_savepoint(true, 2023082200.02); + } + return true; } diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 0b2ab3debcc..5c9457d84eb 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -110,6 +110,15 @@ being forced open in all behat tests. - tiff -> image - wav -> audio - wmv -> video + Apart from that, the following MIME icons have been completely removed: + - clip-353 --> It was added in MDL-75362 by mistake. + - edit + - env + - explore + - folder-open + - help + - move + - parent === 4.2 === diff --git a/pix/f/clip-353 1.png b/pix/f/clip-353 1.png deleted file mode 100644 index 3bcaff57f0b..00000000000 Binary files a/pix/f/clip-353 1.png and /dev/null differ diff --git a/pix/f/dmg-32.png b/pix/f/dmg-32.png deleted file mode 100644 index 89817b9961e..00000000000 Binary files a/pix/f/dmg-32.png and /dev/null differ diff --git a/pix/f/dmg.gif b/pix/f/dmg.gif deleted file mode 100644 index 926ce059a59..00000000000 Binary files a/pix/f/dmg.gif and /dev/null differ diff --git a/pix/f/edit-32.png b/pix/f/edit-32.png deleted file mode 100644 index 79bb52599ce..00000000000 Binary files a/pix/f/edit-32.png and /dev/null differ diff --git a/pix/f/edit.gif b/pix/f/edit.gif deleted file mode 100644 index 893a6e0dd54..00000000000 Binary files a/pix/f/edit.gif and /dev/null differ diff --git a/pix/f/env.gif b/pix/f/env.gif deleted file mode 100644 index 27ff7cdb6d2..00000000000 Binary files a/pix/f/env.gif and /dev/null differ diff --git a/pix/f/explore-32.png b/pix/f/explore-32.png deleted file mode 100644 index 49c69c821cb..00000000000 Binary files a/pix/f/explore-32.png and /dev/null differ diff --git a/pix/f/explore.gif b/pix/f/explore.gif deleted file mode 100644 index b00dbb921ee..00000000000 Binary files a/pix/f/explore.gif and /dev/null differ diff --git a/pix/f/folder-open-128.png b/pix/f/folder-open-128.png deleted file mode 100644 index 92efe7a6f54..00000000000 Binary files a/pix/f/folder-open-128.png and /dev/null differ diff --git a/pix/f/folder-open-24.png b/pix/f/folder-open-24.png deleted file mode 100644 index bcca6f434e2..00000000000 Binary files a/pix/f/folder-open-24.png and /dev/null differ diff --git a/pix/f/folder-open-32.png b/pix/f/folder-open-32.png deleted file mode 100644 index d0fb6980db1..00000000000 Binary files a/pix/f/folder-open-32.png and /dev/null differ diff --git a/pix/f/folder-open-48.png b/pix/f/folder-open-48.png deleted file mode 100644 index 3153f2a35e9..00000000000 Binary files a/pix/f/folder-open-48.png and /dev/null differ diff --git a/pix/f/folder-open-64.png b/pix/f/folder-open-64.png deleted file mode 100644 index 27f7271bd09..00000000000 Binary files a/pix/f/folder-open-64.png and /dev/null differ diff --git a/pix/f/folder-open.png b/pix/f/folder-open.png deleted file mode 100644 index d7ce94b300d..00000000000 Binary files a/pix/f/folder-open.png and /dev/null differ diff --git a/pix/f/help-32.png b/pix/f/help-32.png deleted file mode 100644 index 727dcf8e8d5..00000000000 Binary files a/pix/f/help-32.png and /dev/null differ diff --git a/pix/f/help.gif b/pix/f/help.gif deleted file mode 100644 index cebcf1eb53e..00000000000 Binary files a/pix/f/help.gif and /dev/null differ diff --git a/pix/f/move.gif b/pix/f/move.gif deleted file mode 100644 index 64ad652d4ea..00000000000 Binary files a/pix/f/move.gif and /dev/null differ diff --git a/pix/f/parent-32.png b/pix/f/parent-32.png deleted file mode 100644 index 6c4e4112d8f..00000000000 Binary files a/pix/f/parent-32.png and /dev/null differ diff --git a/pix/f/parent.gif b/pix/f/parent.gif deleted file mode 100644 index 788916a942e..00000000000 Binary files a/pix/f/parent.gif and /dev/null differ diff --git a/version.php b/version.php index af1a3b30d5f..284158b01be 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2023082200.01; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2023082200.02; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes. $release = '4.3dev+ (Build: 20230822)'; // Human-friendly version name