getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.31k stars 168 forks source link

v4.4.0: Custom Routes fail because of #6601 #6676

Closed linusrogge closed 4 weeks ago

linusrogge commented 1 month ago

Description

With the new update to v4.4.0, on a multi-language setup, a set of custom routes lead to an ERR_TOO_MANY_REDIRECTS error, thus breaking the site.

Expected behavior
We have two routes, one that checks for the grid-popup template of the opened page, and redirects from /LANG/SLUG to /LANG/popup/SLUG to avoid confusion with other page’s slugs. The second route then returns the page with the desired url. (We’re using swup with the fragment plugin to add this popup page as an overlay above the current page).

[
  'pattern' => '(:any)',
  'language' => '*',
  'action' => function ($language, $slug) {
    $popup = page($slug);

    if ($popup AND $popup->intendedTemplate() == 'grid-popup') {
      return go($language . '/popup' . '/' . $popup->slug());
    }

    $this->next();
  }
],
[
  'pattern' => 'popup/(:any)',
  'language' => '*',
  'action' => function ($language, $slug) {
    $popup = page($slug);

    if ($popup AND $popup->intendedTemplate() == 'grid-popup') {
      return site()->visit($popup, $language);
    }
  }
]

To reproduce

  1. Set up a multi-language installation of Kirby
  2. Create the blueprints for the popups (content doesn’t matter) and create example pages right in the root of the content folder (and create the translations, without translating the slugs in other languages)
  3. On the home page, create a link pointing to /LANG/popup/SLUG of one of the popups just created
  4. If clicked, “Too many redirects” error should occur

Your setup

Kirby Version
v4.4.0

Your system (please complete the following information)

Additional context
Everything worked fine before updating to v4.4.0, so I figured this will have something to do with the changes made in #6601.

bastianallgeier commented 4 weeks ago

We have a patch release ready that will be released on Monday. You can already give it a try by pulling or downloading https://github.com/getkirby/kirby/tree/release/4.4.1 Please, let us know if the issue has not been fixed by this patch.

linusrogge commented 4 weeks ago

@bastianallgeier Can confirm it works using 4.4.1. Thanks for the quick fix.