CommentFileSizeAuthor
#3 3003019-3.patch2.19 KBwim leers
#2 3003019-2.patch2.2 KBwim leers

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

Status: Active » Needs review
StatusFileSize
new2.2 KB

Relying on a version number is impossible because if jsonapi 2.x or 1.x is installed via a git checkout, it's impossible to determine a version number.

So we need to inspect the actual route definition.

Fortunately, to generate a URL for a route, that same route definition also needs to be retrieved. The performance cost is therefore minimal.

Of course, the result for the first generated URL also applies to all subsequent ones. So static caching is appropriate in this case (JSON API 2.x is not going to be replaced with 1.x mid-request, or vice versa).

And rather than modifying the existing method that is already pretty long, I've added a new helper method. static, to prove it is independent of everything else in the class. But most importantly, to make it trivial to remove in the future :)

Without
PHPUnit 6.5.11 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\decoupled_router\Functional\DecoupledRouterFunctionalTest
E                                                                   1 / 1 (100%)

Time: 9.33 seconds, Memory: 6.00MB

There was 1 error:

1) Drupal\Tests\decoupled_router\Functional\DecoupledRouterFunctionalTest::testNegotiationNoMultilingual
Behat\Mink\Exception\ExpectationException: Current response status code is 500, but 200 expected.

/Users/wim.leers/Work/d8/vendor/behat/mink/src/WebAssert.php:770
/Users/wim.leers/Work/d8/vendor/behat/mink/src/WebAssert.php:130
/Users/wim.leers/Work/d8/modules/decoupled_router/tests/src/Functional/DecoupledRouterFunctionalTest.php:128
/Users/wim.leers/Work/d8/modules/decoupled_router/tests/src/Functional/DecoupledRouterFunctionalTest.php:147
/Users/wim.leers/Work/d8/modules/decoupled_router/tests/src/Functional/DecoupledRouterFunctionalTest.php:148

ERRORS!
Tests: 1, Assertions: 7, Errors: 1.
With
PHPUnit 6.5.11 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\decoupled_router\Functional\DecoupledRouterFunctionalTest
.                                                                   1 / 1 (100%)

Time: 9.72 seconds, Memory: 6.00MB

OK (1 test, 21 assertions)
wim leers’s picture

StatusFileSize
new2.19 KB

Rebased.

mortona2k’s picture

I was getting an error trying to get output for a basic page url, and installing the patch fixed it.

  • e0ipso committed b75a05d on 8.x-1.x authored by Wim Leers
    Issue #3003019 by Wim Leers, mortona2k: JSON API 2.x compatibility
    
e0ipso’s picture

Status: Needs review » Fixed

Thanks for the patch! WFM!

Status: Fixed » Closed (fixed)

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