KES777 / mojo

Mojolicious - Perl real-time web framework
http://mojolicio.us
Artistic License 2.0
0 stars 0 forks source link

'handler' checks in before_render hook when exception occur is not reliable #45

Closed KES777 closed 6 years ago

KES777 commented 6 years ago

This is not a problem, but maybe should be taken into account: Because ->render_maybe changes stash. The M:P:DefaultHandlers:142 implicitly sets up handler to 'ep'. Thus second call to _fallbacks M:P:DefaultHelpers:123 will always try to use ..ep templates

this prevents to check format

KES777 commented 6 years ago

format.t.txt

KES777 commented 6 years ago

https://irclog.perlgeek.de/mojo/2018-05-23#i_16196900

KES777 commented 6 years ago

This is because ->render_maybe changes the stash, even when operation fails.

Look at next surprising code:

package Mojolicoius:Controller:xxx;

sub yyy {
  ....
  $c->stash->{ template } =  'some/template';
  $c->render_maybe( some => 'data' ); # this deletes 'template' stash value
  $c->render;                         # here will xxx/yyy willbe rendered instead of some/template
}