Problem/Motivation

Let's take this route:

some_route:
  path: /example/{argument}/{entity_test}
  defaults:
    _entity_form: 'entity_test.edit'
  options:
    parameters:
      argument:
        type: 'argument_type'

When this route is resolved next PHP error pops up:

Notice: Undefined offset: 1 in Drupal\Core\Entity\EntityResolverManager->setParametersFromEntityInformation() (line 181 of core/lib/Drupal/Core/Entity/EntityResolverManager.php).

This happens only when the non-entity parameter comes first. The "test only" test proves the bug.

Proposed resolution

Fix it.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

claudiu.cristea created an issue. See original summary.

claudiu.cristea’s picture

And the fix.

claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Issue tags: +Quick fix

The last submitted patch, routing_error-test-only.patch, failed testing.

dawehner’s picture

+++ b/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php
@@ -385,6 +385,38 @@ public function testSetRouteOptionsWithEntityFormRoute() {
+    self::assertEquals($expect, $parameters);

Why do we not use $this->assertEquals as in every other patch? I know why you did that, but it might confuse people as every phpunit documentation uses $this->assertEquals

claudiu.cristea’s picture

OK :)

claudiu.cristea’s picture

Reveal the test-only patch in the list.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Looks perfect for me

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Nice fix. Committed and pushed 9bc59ded3e700fe2e46907df41d06998a9ec3a47 to 8.2.x and 8091985 to 8.1.x. Thanks!

  • alexpott committed 9bc59de on 8.2.x
    Issue #2776055 by claudiu.cristea: Entity form/view route errors when a...

  • alexpott committed 8091985 on 8.1.x
    Issue #2776055 by claudiu.cristea: Entity form/view route errors when a...

  • alexpott committed 9bc59de on 8.3.x
    Issue #2776055 by claudiu.cristea: Entity form/view route errors when a...

  • alexpott committed 9bc59de on 8.3.x
    Issue #2776055 by claudiu.cristea: Entity form/view route errors when a...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.