diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php index 11e3711..a01d93c 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php @@ -364,6 +364,13 @@ protected function preSave(array &$link, array $original) { // text field. $fields['route_param_key'] = $fields['route_parameters'] ? UrlHelper::buildQuery($fields['route_parameters']) : ''; + if (isset($fields['title'])) { + $fields['title_serialized'] = $fields['title']; + unset($fields['title']); + $fields['description_serialized'] = $fields['description']; + unset($fields['description']); + } + foreach ($this->serializedFields() as $name) { if (isset($fields[$name])) { $fields[$name] = serialize($fields[$name]); @@ -623,6 +630,16 @@ protected function prepareLink(array $link, $intersect = FALSE) { $link[$name] = unserialize($link[$name]); } } + + if (isset($link['title_serialized'])) { + $link['title'] = $link['title_serialized']; + unset($link['title_serialized']); + } + if (isset($link['description_serialized'])) { + $link['description'] = $link['description_serialized']; + unset($link['description_serialized']); + } + if ($intersect) { $link = array_intersect_key($link, array_flip($this->definitionFields())); } @@ -1249,14 +1266,14 @@ protected static function schemaDefinition() { 'not null' => TRUE, 'default' => '', ), - 'title' => array( + 'title_serialized' => array( 'description' => 'The title for the link. May be a serialized TranslationWrapper', 'type' => 'blob', 'size' => 'big', 'not null' => FALSE, 'serialize' => TRUE, ), - 'description' => array( + 'description_serialized' => array( 'description' => 'The description of this link - used for admin pages and title attribute.', 'type' => 'blob', 'size' => 'big', diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 91ca627..c5a5623 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1099,7 +1099,7 @@ function system_update_8001() { 'not null' => FALSE, 'serialize' => TRUE, ); - db_change_field('menu_tree', 'title', 'title', $spec); + db_add_field('menu_tree', 'title_serialized', $spec); $spec = array( 'description' => 'The description of this link - used for admin pages and title attribute.', 'type' => 'blob', @@ -1107,7 +1107,7 @@ function system_update_8001() { 'not null' => FALSE, 'serialize' => TRUE, ); - db_change_field('menu_tree', 'description', 'description', $spec); + db_add_field('menu_tree', 'description_serialized', $spec); } } @@ -1127,17 +1127,18 @@ function system_update_8002(&$sandbox = NULL) { $return = []; foreach ($menu_links as $menu_link) { + $menu_link = (array) $menu_link; $menu_link['title_arguments'] = unserialize($menu_link['title_arguments']); $menu_link['title_context'] = unserialize($menu_link['title_context']); // Convert static defined plugins to use t(). if ($menu_link['class'] === 'Drupal\Core\Menu\MenuLinkDefault') { - $menu_link['title'] = serialize(new TranslationWrapper($menu_link['title'], $menu_link['title_arguments'], ['context' => $menu_link['title_context']])); + $menu_link['title_serialized'] = serialize(new TranslationWrapper($menu_link['title'], $menu_link['title_arguments'], ['context' => $menu_link['title_context']])); } else { - $menu_link['title'] = serialize($menu_link['title']); + $menu_link['title_serialized'] = serialize($menu_link['title']); } - $menu_link['description'] = serialize($menu_link['description']); + $menu_link['description_serialized'] = serialize($menu_link['description']); unset($menu_link['title_arguments']); unset($menu_link['title_context']); @@ -1151,9 +1152,9 @@ function system_update_8002(&$sandbox = NULL) { $sandbox['current']++; } - $return['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['current'] / $sandbox['max']); + $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['current'] / $sandbox['max']); - return $return; + return t('Menu links converted'); } /** @@ -1162,4 +1163,6 @@ function system_update_8002(&$sandbox = NULL) { function system_update_8003() { db_drop_field('menu_tree', 'title_arguments'); db_drop_field('menu_tree', 'title_context'); + db_drop_field('menu_tree', 'title'); + db_drop_field('menu_tree', 'description'); } diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index 9d806bb..a656ab3 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -454,6 +454,8 @@ system.db_update: _title: 'Drupal database update' _controller: '\Drupal\system\Controller\DbUpdateController::handle' op: 'info' + options: + _maintenance_access: TRUE requirements: _access_system_update: 'TRUE'