diff -u b/core/modules/menu_ui/src/MenuForm.php b/core/modules/menu_ui/src/MenuForm.php --- b/core/modules/menu_ui/src/MenuForm.php +++ b/core/modules/menu_ui/src/MenuForm.php @@ -213,6 +213,7 @@ protected function buildOverviewForm(array &$form, FormStateInterface $form_state) { // Ensure that menu_overview_form_submit() knows the parents of this form // section. + $form['#tree'] = TRUE; if (!$form_state->has('menu_overview_form_parents')) { $form_state->set('menu_overview_form_parents', []); } @@ -280,10 +281,14 @@ if (isset($links[$id]['#item'])) { $element = $links[$id]; + $form['links'][$id]['#item'] = $element['#item']; + // TableDrag: Mark the table row as draggable. $form['links'][$id]['#attributes'] = $element['#attributes']; $form['links'][$id]['#attributes']['class'][] = 'draggable'; + $form['links'][$id]['#item'] = $element['#item']; + // TableDrag: Sort the table row according to its existing/configured weight. $form['links'][$id]['#weight'] = $element['#item']->link->getWeight(); @@ -302,11 +307,9 @@ $form['links'][$id]['enabled'] = $element['enabled']; $form['links'][$id]['enabled']['#wrapper_attributes']['class'] = array('checkbox', 'menu-enabled'); - $form['links'][$id]['weight'] = array( - $element['weight'], - $element['parent'], - $element['id'], - ); + $form['links'][$id]['weight'] = $element['weight']; + $form['links'][$id]['id'] = $element['id']; + $form['links'][$id]['parent'] = $element['parent']; // Operations (dropbutton) column. $form['links'][$id]['operations'] = $element['operations']; @@ -440,9 +443,10 @@ $form = array_intersect_key(array_merge($order, $form), $form); $fields = array('weight', 'parent', 'enabled'); - foreach (Element::children($form) as $id) { - if (isset($form[$id]['#item'])) { - $element = $form[$id]; + $form_links = $form['links']; + foreach (Element::children($form_links) as $id) { + if (isset($form_links[$id]['#item'])) { + $element = $form_links[$id]; $updated_values = array(); // Update any fields that have changed in this menu item. foreach ($fields as $field) { only in patch2: unchanged: --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -323,7 +323,19 @@ function file_create_url($uri) { else { // If this is not a properly formatted stream, then it is a shipped file. // Therefore, return the urlencoded URI with the base URL prepended. - return $GLOBALS['base_url'] . '/' . UrlHelper::encodePath($uri); + $options = UrlHelper::parse($uri); + $path = $GLOBALS['base_url'] . '/' . UrlHelper::encodePath($options['path']); + // Append the query. + if ($options['query']) { + $path .= '?' . UrlHelper::buildQuery($options['query']); + } + + // Append fragment. + if ($options['fragment']) { + $path .= '#' . $options['fragment']; + } + + return $path; } } elseif ($scheme == 'http' || $scheme == 'https' || $scheme == 'data') { only in patch2: unchanged: --- a/core/modules/system/src/Tests/File/UrlRewritingTest.php +++ b/core/modules/system/src/Tests/File/UrlRewritingTest.php @@ -56,6 +56,18 @@ function testShippedFileURL() { $filepath = 'core/misc/favicon.ico'; $url = file_create_url($filepath); $this->assertEqual('/' . base_path() . '/' . $filepath, $url, 'Correctly generated a protocol-relative URL for a shipped file.'); + + // Test alteration of file URLs with query strings and/or fragment. + \Drupal::state()->delete('file_test.hook_file_url_alter'); + $filepath = 'core/misc/favicon.ico'; + $url = file_create_url($filepath . '?foo'); + $this->assertEqual($GLOBALS['base_url'] . '/' . $filepath . '?foo=', $url, 'Correctly generated url. The query string is present.'); + $url = file_create_url($filepath . '?foo=bar'); + $this->assertEqual($GLOBALS['base_url'] . '/' . $filepath . '?foo=bar', $url, 'Correctly generated url. The query string is present.'); + $url = file_create_url($filepath . '#v1.2'); + $this->assertEqual($GLOBALS['base_url'] . '/' . $filepath . '#v1.2', $url, 'Correctly generated url. The fragment is present.'); + $url = file_create_url($filepath . '?foo=bar#v1.2'); + $this->assertEqual($GLOBALS['base_url'] . '/' . $filepath . '?foo=bar#v1.2', $url, 'Correctly generated url. The query string amd fragment is present.'); } /**