diff --git a/core/modules/system/src/Tests/Menu/MenuTreeStorageTest.php b/core/modules/system/src/Tests/Menu/MenuTreeStorageTest.php index 1df4050..57f1f2a 100644 --- a/core/modules/system/src/Tests/Menu/MenuTreeStorageTest.php +++ b/core/modules/system/src/Tests/Menu/MenuTreeStorageTest.php @@ -354,7 +354,6 @@ protected function addMenuLink($id, $parent = '', $route_name = 'test', $route_p 'menu_name' => $menu_name, 'route_name' => $route_name, 'route_parameters' => $route_parameters, - 'title_arguments' => array(), 'title' => 'test', 'parent' => $parent, 'options' => array(), diff --git a/core/modules/system/src/Tests/Update/UpdatePathTestBase.php b/core/modules/system/src/Tests/Update/UpdatePathTestBase.php index fb365f0..7b19bf0 100644 --- a/core/modules/system/src/Tests/Update/UpdatePathTestBase.php +++ b/core/modules/system/src/Tests/Update/UpdatePathTestBase.php @@ -185,7 +185,14 @@ protected function runUpdates() { $this->fail('Missing zlib requirement for upgrade tests.'); return FALSE; } - $this->drupalLogin($this->rootUser); + + // The site might be broken at the time so logging in using the UI might + // not work, so we use the API itself. + drupal_rewrite_settings(['settings' => ['update_free_access' => (object) [ + 'value' => TRUE, + 'required' => TRUE, + ]]]); + $this->drupalGet($this->updateUrl); $this->clickLink(t('Continue')); diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 6d3c888..91ca627 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -8,6 +8,7 @@ use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Environment; use Drupal\Component\Utility\SafeMarkup; +use Drupal\Core\StringTranslation\TranslationWrapper; use Drupal\Core\Url; use Drupal\Core\Database\Database; use Drupal\Core\DrupalKernel; @@ -1107,10 +1108,58 @@ function system_update_8001() { 'serialize' => TRUE, ); db_change_field('menu_tree', 'description', 'description', $spec); - db_update('menu_tree') - ->fields(array('title' => NULL, 'description' => NULL)) + } +} + +/** + * Update the {menu_tree} table to convert the serialized data. + */ +function system_update_8002(&$sandbox = NULL) { + $database = \Drupal::database(); + if (!isset($sandbox['progress'])) { + $sandbox['progress'] = 0; + // Start at 1 to skip the anonymous user. + $sandbox['current'] = 1; + $sandbox['max'] = $database->query('SELECT COUNT(*) FROM {menu_tree}')->fetchField(); + } + + $menu_links = $database->queryRange('SELECT * FROM {menu_tree} ORDER BY mlid ASC', $sandbox['current'], $sandbox['current'] + 10)->fetchAllAssoc('mlid'); + + $return = []; + foreach ($menu_links as $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']])); + } + else { + $menu_link['title'] = serialize($menu_link['title']); + } + $menu_link['description'] = serialize($menu_link['description']); + + unset($menu_link['title_arguments']); + unset($menu_link['title_context']); + + $database->update('menu_tree') + ->fields($menu_link) + ->condition('mlid', $menu_link['mlid']) ->execute(); - db_drop_field('menu_tree', 'title_arguments'); - db_drop_field('menu_tree', 'title_context'); + + $sandbox['progress']++; + $sandbox['current']++; } -} \ No newline at end of file + + $return['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['current'] / $sandbox['max']); + + return $return; +} + +/** + * Drop unnecessary fields from {menu_tree}. + */ +function system_update_8003() { + db_drop_field('menu_tree', 'title_arguments'); + db_drop_field('menu_tree', 'title_context'); +}