Named route with tokens does not redirect

127 views
Skip to first unread message

Alexandre Plennevaux

unread,
Nov 15, 2017, 12:30:17 PM11/15/17
to Fat-Free Framework


I have a rerouting of a named route that works locally but not on the production server.

I took this out of the documentation:
$f3->route('GET @beer_list: /beer/@country', 'Beer->bycountry');
$f3->reroute('@beer_list(@country=Germany)');

In my code :

$f3->route('GET @startup: /startup/@promoid', 'Controller\Inside->start');


and in the controller :

      $f3->reroute("@startup(@promoid=$current_promo)");



On my testing server, the redirection works fine.
On the production server, the redirected url become : http://domain/com//@startup(bxlcentral-promo-1=bxlcentral-promo-1)
and thus triggers a 404.  It seems it replaces both the key and the value with the value.

FYI : the production server runs on apache 2.4.17 with modrewrite active.

I'm not exactly sure what goes on here. Any help would be welcome.

ikkez

unread,
Nov 15, 2017, 12:39:16 PM11/15/17
to Fat-Free Framework
maybe a different php version which could effect how the $current_promo is handled in your quoted string.. have you tried instead:

$f3->reroute('@startup(@promoid='.$current_promo.')');

Alexandre Plennevaux

unread,
Nov 15, 2017, 4:26:50 PM11/15/17
to Fat-Free Framework
Thank you for your fast reply. There is a slight change (local is 7.0.20, prod is PHP7.0.21, apache 2.4.27) but local is debian and prod is redhat. A system update was performed (it's an AWS EC2 machine) and there were a few PHP Warning for "already loaded" modules, that I just resolved. But still, no go:

500 Internal Server Error
<h1>Internal Server Error</h1>
<p>Named route does not exist: startup</p>


Every component is there.  httpd.conf shows that AllowOveride all (so I get that mod_rewrite is active).

Do you have any idea where I should look at (what does the f3 alias need in order to recognize the named route ?) ?

Alexandre Plennevaux

unread,
Nov 15, 2017, 4:47:02 PM11/15/17
to Fat-Free Framework
The exact line triggering the error is this :

      <option value="{{ 'startup', 'promoid='.@promo->github_team_slug | alias }}" {{ @current_promo == @promo->github_team_slug ? "selected" : "" }}>{{ @promo->name }} ({{ @promo->total_students }})</option>

xfra35

unread,
Nov 15, 2017, 4:56:29 PM11/15/17
to Fat-Free Framework
This error indicates that "startup" is not a recognized alias. You can easily check if it's defined by dumping $f3->ALIASES.

What about your initial error (rerouting)? Is it still there?

Alexandre Plennevaux

unread,
Nov 15, 2017, 7:45:50 PM11/15/17
to xfra35 via Fat-Free Framework
Dumping the ALIASES was a great advise as it lead me to the cause : caching.

For the same set of routes:

$f3->route('GET @home: /', 'Controller\Inside->login');
$f3->route('GET @stage-entreprise: /stage-entreprise.html', 'Controller\Outside->stagesEntreprise');
$f3->route('GET @getbadges: /get-badges/@username', 'Controller\CodeAcademy->getBadges');
$f3->route('GET|POST @login: /login', 'Controller\Inside->login');
$f3->route('GET @logout: /logout', 'Controller\Inside->logout');
$f3->route('GET @student: /startup/@promoid/student/@studentid', 'Controller\Inside->start');
$f3->route('GET @startup: /startup/@promoid', 'Controller\Inside->start');
$f3->route('GET @start: /startup', 'Controller\Inside->start');
$f3->route('GET @external_sync: /sync', 'Controller\Inside->sync');
$f3->route('GET /binome/@amount', 'Controller\Binome->random');
$f3->route('GET @binome_generator_app: /binome', 'Controller\Binome->random');
$f3->route('GET|POST @github_callback: /sso/callback', 'Controller\Inside->callback');


locally dumping $f3->ALIASES shows this :

Array
(
    [home] => /
    [stage-entreprise] => /stage-entreprise.html
    [getbadges] => /get-badges/@username
    [login] => /login
    [logout] => /logout
    [student] => /startup/@promoid/student/@studentid
    [startup] => /startup/@promoid
    [start] => /startup
    [external_sync] => /sync
    [binome_generator_app] => /binome
    [github_callback] => /sso/callback
)

Whereas on prod I get this :

Array
(
    [home] => /
    [stage-entreprise] => /stage-entreprise.html
    [getbadges] => /get-badges/@username
    [login] => /login
    [logout] => /logout
    [student] => /promo/@promoid/student/@studentid
    [start] => /start
    [external_sync] => /sync
    [binome_generator_app] => /binome
    [github_callback] => /sso/callback
)
So indeed, the startup alias is missing, and the "startup" URL is wrong. It is actually outdated (the student route is an old one). Apparently the route change did not provoke a refresh of the cache. So I manually emptied the /tmp folder and... it solved it.

Thank you !!


On 15 November 2017 at 22:56, xfra35 via Fat-Free Framework <f3-framework+APn2wQdllyYRCbrJQTu...@googlegroups.com> wrote:
This error indicates that "startup" is not a recognized alias. You can easily check if it's defined by dumping $f3->ALIASES.

What about your initial error (rerouting)? Is it still there?

--
-- You've received this message because you are subscribed to the Google Groups group. To post to this group, send an email to f3-fra...@googlegroups.com. To unsubscribe from this group, send an email to f3-framework+unsubscribe@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/f3-framework?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Fat-Free Framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/f3-framework/ykq98cktYJY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to f3-framework+unsubscribe@googlegroups.com.
To post to this group, send email to f3-fra...@googlegroups.com.
Visit this group at https://groups.google.com/group/f3-framework.
To view this discussion on the web visit https://groups.google.com/d/msgid/f3-framework/3ff55577-43f3-4d94-84e8-ea12c364ee1c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages