 core/includes/menu.inc                             | 17 ++++++++++++++++-
 core/modules/image/image.module                    | 10 +++++-----
 .../lib/Drupal/system/Tests/Menu/RouterTest.php    |  9 +++++++++
 .../tests/modules/menu_test/menu_test.module       | 22 +++++++++++++++++++---
 5 Dateien geändert, 50 Zeilen hinzugefügt(+), 10 Zeilen entfernt(-)

diff --git a/core/includes/menu.inc b/core/includes/menu.inc
index 6492b10..346a8b9 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -531,7 +531,22 @@ function _menu_load_objects(&$item, &$map) {
               $args[$i] = &$map;
             }
             if (is_int($arg)) {
-              $args[$i] = isset($path_map[$arg]) ? $path_map[$arg] : '';
+              // If we loaded the specified $arg index in already, supply the
+              // loaded argument. This is the case when e.g. two dynamic
+              // placeholders appear within a single router path, and the
+              // 'load arguments' specify the integer index of the first
+              // argument, in order to pass the loaded argument to the second
+              // argument loader.
+              if (isset($map[$arg])) {
+                $args[$i] = $map[$arg];
+              }
+              // Otherwise, supply the string argument, if any.
+              elseif (isset($path_map[$arg])) {
+                $args[$i] = $path_map[$arg];
+              }
+              else {
+                $args[$i] = '';
+              }
             }
           }
           array_unshift($args, $value);
diff --git a/core/modules/image/image.module b/core/modules/image/image.module
index 221e07c..f0d9095 100644
--- a/core/modules/image/image.module
+++ b/core/modules/image/image.module
@@ -66,7 +66,7 @@ function image_help($path, $arg) {
       $effect = image_effect_definition_load($arg[7]);
       return isset($effect['help']) ? ('<p>' . $effect['help'] . '</p>') : NULL;
     case 'admin/config/media/image-styles/edit/%/effects/%':
-      $effect = ($arg[5] == 'add') ? image_effect_definition_load($arg[6]) : image_effect_load($arg[6], $arg[4]);
+      $effect = ($arg[5] == 'add') ? image_effect_definition_load($arg[7]) : menu_get_object('image_effect', 7);
       return isset($effect['help']) ? ('<p>' . $effect['help'] . '</p>') : NULL;
   }
 }
@@ -1004,8 +1004,8 @@ function image_effects() {
  *
  * @param $ieid
  *   The image effect ID.
- * @param $style_name
- *   The image style name.
+ * @param \Drupal\image\Plugin\Core\Entity\ImageStyle $style
+ *   The image style.
  *
  * @return
  *   An image effect array, consisting of the following keys:
@@ -1018,8 +1018,8 @@ function image_effects() {
  *   found.
  * @see image_effect_definition_load()
  */
-function image_effect_load($ieid, $style_name) {
-  if (($style = entity_load('image_style', $style_name)) && isset($style->effects[$ieid])) {
+function image_effect_load($ieid, $style) {
+  if (isset($style->effects[$ieid])) {
     $effect = $style->effects[$ieid];
     $definition = image_effect_definition_load($effect['name']);
     $effect = array_merge($definition, $effect);
diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/RouterTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/RouterTest.php
index 179ea93..0597e5f 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Menu/RouterTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Menu/RouterTest.php
@@ -575,4 +575,13 @@ function testMenuLoadArgumentsInheritance() {
       $this->assertIdentical(unserialize($router_item['load_functions']), $load_functions, format_string('Expected load functions for router %router_path' , array('%router_path' => $router_path)));
     }
   }
+
+  /**
+   * Tests that objects are passed to menu loaders when available.
+   */
+  public function testMenuLoadArgumentObjects() {
+    $this->drupalGet('menu-test/load-argument-object/first/second');
+    // @see menu_test_other_argument_load()
+    $this->assertText('Object correctly passed to menu loader.');
+  }
 }
diff --git a/core/modules/system/tests/modules/menu_test/menu_test.module b/core/modules/system/tests/modules/menu_test/menu_test.module
index 36cef57..019179e 100644
--- a/core/modules/system/tests/modules/menu_test/menu_test.module
+++ b/core/modules/system/tests/modules/menu_test/menu_test.module
@@ -363,6 +363,18 @@ function menu_test_menu() {
     'access callback' => TRUE,
   );
 
+  // Test that, when using two menu loaders, and the load arguments reference
+  // the first one, the second load function gets the loaded object passed
+  // instead of the integer index.
+  // @todo This router cannot be in the menu-test/arguments namespace because
+  //   that would already be matched by the routers above.
+  $items['menu-test/load-argument-object/%menu_test_argument/%menu_test_other_argument'] = array(
+    'title' => 'An item with menu load arguments that are objects',
+    'load arguments' => array(2),
+    'page callback' => 'menu_test_callback',
+    'access callback' => TRUE,
+  );
+
   return $items;
 }
 
@@ -370,14 +382,18 @@ function menu_test_menu() {
  * Dummy argument loader for hook_menu() to point to.
  */
 function menu_test_argument_load($arg1) {
-  return FALSE;
+  return (object) array('foo' => 'bar');
 }
 
 /**
  * Dummy argument loader for hook_menu() to point to.
  */
-function menu_test_other_argument_load($arg1) {
-  return FALSE;
+function menu_test_other_argument_load($arg1, $arg2 = NULL) {
+  if (is_object($arg2) && ($arg2->foo == 'bar')) {
+    // @todo drupal_set_message() does not work here.
+    debug('Object correctly passed to menu loader.');
+  }
+  return $arg1;
 }
 
 /**
