distantnative / retour-for-kirby

Kirby CMS plugin to manage redirects and track 404s right from the Panel
https://distantnative.com/retour-for-kirby/
MIT License
135 stars 15 forks source link

TypeError for routes returning arrays #275

Closed thathoff closed 2 years ago

thathoff commented 2 years ago

Describe the bug

The route:after closure expects the 4th argument ($result) to be a String. But in some cases Kirby does not insert a string here. This happens for example if you have a custom route returning an array.

Steps to reproduce

  1. Install Retour 4.0.0.beta-1
  2. Setup a custom route returning an array like this
    [
    'pattern' => 'retourtest',
    'action' => function () {
        return ['foo' => 'bar'];
     }
    ],
  3. Visit that route
  4. TypeError Argument 4 passed to Kirby\Cms\App::distantnative\Retour\{closure}() must be of the type string or null, array given is thrown.

Expected behavior

No TypeError thrown.

iskrisis commented 2 years ago

Came to report this - i confirm fix worked for me.

distantnative commented 2 years ago

Great, will try to release a new beta this weekend - thanks @thathoff

distantnative commented 2 years ago

✅ Will be fixed in 4.0 release