MDL-74597 themes: remove pix icon references from custom menu items.

Support for them was removed in 8c336899, however existing config
remained that would lead to bogus URLs in custom user menu items.
This commit is contained in:
Paul Holden
2022-06-13 21:43:28 +01:00
parent ca583bddaf
commit e1fefe2e14
2 changed files with 25 additions and 3 deletions
+24 -2
View File
@@ -3235,8 +3235,13 @@ privatefiles,moodle|/user/files.php';
set_config('customusermenuitems', $newcustomusermenuitems);
} else {
// If the site is not using the old defaults, only add necessary entries.
$lines = explode("\n", $currentcustomusermenuitems);
$lines = array_map('trim', $lines);
$lines = preg_split('/\n/', $currentcustomusermenuitems, -1, PREG_SPLIT_NO_EMPTY);
$lines = array_map(static function(string $line): string {
// Previous format was "<langstring>|<url>[|<pixicon>]" - pix icon is no longer supported.
$lineparts = explode('|', trim($line), 3);
// Return first two parts of line.
return implode('|', array_slice($lineparts, 0, 2));
}, $lines);
// Remove the Preference entry from the menu to prevent duplication
// since it will be added again in user_get_user_navigation_info().
@@ -4565,5 +4570,22 @@ privatefiles,moodle|/user/files.php';
upgrade_main_savepoint(true, 2022060300.01);
}
if ($oldversion < 2022061000.01) {
// Iterate over custom user menu items configuration, removing pix icon references.
$customusermenuitems = str_replace(["\r\n", "\r"], "\n", $CFG->customusermenuitems);
$lines = preg_split('/\n/', $customusermenuitems, -1, PREG_SPLIT_NO_EMPTY);
$lines = array_map(static function(string $line): string {
// Previous format was "<langstring>|<url>[|<pixicon>]" - pix icon is no longer supported.
$lineparts = explode('|', trim($line), 3);
// Return first two parts of line.
return implode('|', array_slice($lineparts, 0, 2));
}, $lines);
set_config('customusermenuitems', implode("\n", $lines));
upgrade_main_savepoint(true, 2022061000.01);
}
return true;
}
+1 -1
View File
@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2022061000.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2022061000.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '4.1dev (Build: 20220610)'; // Human-friendly version name