If you have a look at RouteProvider::getRouteByNames() you can spot for example that $this->table is now $this->tableName.

Other issues: array_intersect_key uses the wrong parameter, RouteNotFoundException wasn't used etc.

I ran into that while writing tests, so tagging.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs review
Issue tags: +WSCCI
FileSize
5.73 KB

Add tag and tests and fixes :)

Crell’s picture

+++ b/core/lib/Drupal/Core/Routing/RouteProvider.php
@@ -151,19 +155,20 @@ public function getRouteByName($name, $parameters = array()) {
+   * @param array $parameters
+   *   The parameters as they are passed to the UrlGeneratorInterface::generate
+   *   call. (Only one array, not one for each entry in $names.

Missing ending ).

+++ b/core/modules/system/lib/Drupal/system/Tests/Routing/RouteProviderTest.php
@@ -319,4 +320,39 @@ function testSystemPathMatch() {
+    $exception_thrown = FALSE;
+    try {
+      $provider->getRouteByName($this->randomName());
+    }
+    catch (RouteNotFoundException $e) {
+      $exception_thrown = TRUE;
+    }
+    $this->assertTrue($exception_thrown, 'Random route was not found.');

This is strictly speaking not safe, as there is a non-zero (if remote) chance that randomName() will return "route_a".

I don't think it will ever happen but it's not make testbot any more non-deterministic than it already is. :-)

And Crell-- for letting such blatant bugs through in the first place. :-( Thanks for the catch, Daniel!

dawehner’s picture

FileSize
6.21 KB
2.18 KB

Thanks for the review!

I think having a proper name also helps to understand what is going on a bit better.
Btw. it's incredible awesome to write tests which are executed instantaneous!
This remembers me the old days of fully unit testing code in the university.

Crell’s picture

Status: Needs review » Reviewed & tested by the community

Yay bug fixes.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Eek, nice find. Committed/pushed to 8.x.

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