diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 8fd277ebe8f..1e4b3db6827 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -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 "|[|]" - 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 "|[|]" - 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; } diff --git a/version.php b/version.php index 5a0f0c28bf3..bd6eb45cc29 100644 --- a/version.php +++ b/version.php @@ -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