MDL-78884 pix: Remove invalid or deprecated MIME icons
The following MIME icons have been completely removed because they were not used (they were probably added/kept by mistake): - clip-353 --> It was added in MDL-75362 by mistake. - edit - env - explore - folder-open - help - move - parent Apart from removing these MIME icons, a PHPUnit test has been added to guarantee MIME icons in pix/f are under control and they are only added/removed when needed.
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 ===
|
||||
|
||||
|
Before Width: | Height: | Size: 29 KiB |
BIN
pix/f/dmg-32.png
Before Width: | Height: | Size: 1.4 KiB |
BIN
pix/f/dmg.gif
Before Width: | Height: | Size: 222 B |
Before Width: | Height: | Size: 1.4 KiB |
BIN
pix/f/edit.gif
Before Width: | Height: | Size: 262 B |
BIN
pix/f/env.gif
Before Width: | Height: | Size: 249 B |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 239 B |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 539 B |
Before Width: | Height: | Size: 623 B |
Before Width: | Height: | Size: 965 B |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 331 B |
Before Width: | Height: | Size: 2.0 KiB |
BIN
pix/f/help.gif
Before Width: | Height: | Size: 237 B |
BIN
pix/f/move.gif
Before Width: | Height: | Size: 128 B |
Before Width: | Height: | Size: 1.1 KiB |
BIN
pix/f/parent.gif
Before Width: | Height: | Size: 138 B |
@ -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
|
||||
|