https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42663
--- Comment #15 from David Cook <[email protected]> --- (In reply to Jonathan Druart from comment #14) > (In reply to David Cook from comment #13) > > But now that I think about it - why use an environmental variable at all? It > > can just exist within a variable in Koha::Context. You can just my $instance > > at the file level in Koha::Context and it's all good. > > Nope, Julian found a bug on bug 41972. We don't want it to persist between 2 > requests. We can store it in the L1 cache, but this trick felt more > Mojo-oriented and more inline with our "ultimate" goal. I see what you mean. I was thinking more about globals like Koha::Context->config() which should be fine to be persisted, but a request-scoped $context->userenv would not be. That could be a problem for a app level singleton (unless you reset the request-scoped data but yeah better to use the environmental variables). You've inspired me a bit with your Mojo reference... When I think about frameworks like Mojolicious or Catalyst, I think about their $c controller context object. And in those cases you'd have $c->session instead of $context->userenv. So if I look at: https://metacpan.org/dist/Plack-Middleware-Session/source/lib/Plack/Middleware/Session.pm. I see that they do pass a Plack::Session object through, just like we're passing a Koha::Context object in $env->{'koha.context'}. Looking at that Plack Middleware, we might want to consider using a key like "psgix.koha.context". (In reply to Jonathan Druart from comment #12) > > Koha::Context shouldn't depend on Koha::Middleware::Context. In fact, I > > don't think that we really need Koha::Middleware::Context. All > > Koha::Context->current() needs to do is return a singleton. So check for the > > $ENV{"koha.context"}. If it's set, return its contents. If it's not set, set > > it. That's it. > > We cannot store structures in ENV, only strings. That's why I need to reuse > the psgi_env var from the middleware. I don't understand this. We are already storing structures in a PSGI environment. Why would we need to store a structure in an "ENV" environmental variable? Is it because of the CGI scripts? Note that https://metacpan.org/pod/Plack::Component#OBJECT-LIFECYCLE warns against saving per-request data in the object (and that would be especially true for an "our" variable as well). -- Overall, I think that we're mixing up a number of things here still, and it's probably because of the CGI scripts. If/when the app is 100% a Plack app or 100% a Mojo app, then we'll be able to easily handle things at the beginning and ending of the request cycle. -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
