Cakephp: BC breaking change to routes in 3.8.8

Created on 25 Feb 2020  路  3Comments  路  Source: cakephp/cakephp

This is a (multiple allowed):

  • [x] bug
  • [ ] enhancement
  • [ ] feature-discussion (RFC)

  • CakePHP Version: 3.8.8 and newer

What you did

Updated to 3.8.8

What happened

Some tests started to fail that check for correct URLs.

1) App\Test\TestCase\View\Helper\SearchFilterHelperTest::testRemoveQueryParam
Cake\Routing\Exception\MissingRouteException: A route matching "array (
  '?' =>
  array (
    'section' => 'profiles',
    'preserve' => 1,
  ),
  'language' => 'en',
  'action' => 'index',
  'plugin' => NULL,
  'controller' => NULL,
  '_ext' => NULL,
)" could not be found.

I think this is related to the change mentioned in the notes here https://bakery.cakephp.org/2019/12/28/cakephp_388_released.html

When generating URLs, routes with controller and action placeholders no longer strip these these keys when they are undefined. Instead routes missing the controller and action keys will fail to match.

What you expected to happen

No BC breaking behavior because of a patch release! 馃槧 Cake is still using https://semver.org/ right?

Is there any workaround that can be applied globally to this problem or will I have to manually merge the URL array in all places that don't use the controller and action key? This basically means I'll have to do this in all the places that somehow build an URL.

            $url = [
                'plugin' => $request->getParam('plugin'),
                'controller' => $request->getParam('controller'),
                'action' => $request->getParam('action'),
                '?' => array_merge($query, ['char' => $char])
            ];

Most helpful comment

The previous behavior was not correct and was masked by incorrect tests. If you are unable to fix your tests you can pin to 3.8.7.

All 3 comments

This is only happening inside a test case, correct?
I had to fix up my tests here as well. If you just set some value for the controller the test case will work again fine.

So far it seems to happen only in the tests but how can I trust the framework and app if we have failing tests because of a change in the framework? This is also hard to sell to my boss for obvious reasons.

The previous behavior was not correct and was masked by incorrect tests. If you are unable to fix your tests you can pin to 3.8.7.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

berarma picture berarma  路  3Comments

cleptric picture cleptric  路  3Comments

nrother picture nrother  路  3Comments

dereuromark picture dereuromark  路  3Comments

caBBAlainB picture caBBAlainB  路  4Comments