xfra35 / f3-multilang

Create multilingual apps with this localization plugin for the PHP Fat-Free Framework
GNU General Public License v3.0
48 stars 13 forks source link

OnReroute doesn't work with newest F3 update #22

Closed dtSniper closed 4 years ago

dtSniper commented 4 years ago

I use f3-Multilang on most public sites and I exclude a few sites that are for logged in users like admins.

after the last update, I have the following problem. I use an ONREROUTE rule to ml reroute if needed.

$f3->set( 'ONREROUTE', function ($url, $permanent) use ($f3, $ml) {
        if (!$ml->isGlobal( $url ) && !in_array( $url, $f3->get( "excludedRedirects" ) )) {
            $f3->clear( 'ONREROUTE' );
            $ml->reroute( $url, $permanent );
        }
        else {
            return false;
        }
    } );

this way I can still use f3 reroute without sending the language.

After the latest F3 update the following problem happens: whenever a reroute happens to a dynamic URL the URL in ONREROUTE doesn't have the "REAL" URL but the URL with the params.

so let's say I got the URL /blog/@article so normally if i would reroute to (or someone links links to) /blog/1 it should be sent to /en/blog/1 but suddenly I get errors. I traced it down to f3-Multilang being active and ONREROUTE. the $url Variable in the OnReroute Function will suddenly say: /blog/@article instead of /blog/1

xfra35 commented 4 years ago

This issue sounds similar to #21.

Have you tried upgrading to https://github.com/bcosca/fatfree-core/commit/bab17f84621cdab037ee7771e4ede6acf9a70d72?

dtSniper commented 4 years ago

at the moment we are rolling back F3. We will check this when we have mor time to deal with unforseen problems

xfra35 commented 4 years ago

Alright. I'm closing it as I'm pretty sure this is an upstream bug, fixed in https://github.com/bcosca/fatfree-core/commit/bab17f84621cdab037ee7771e4ede6acf9a70d72.

If anything, come back and we'll have a further look.