-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$app->persistent (Session bag) fatal error on 3.2.0 (Invalid superglobal) #12918
Comments
Well as a workaround for issue: $di->set('session', function(){
$session = new \Phalcon\Session\Adapter\Files();
$session->start(); // we need to start session
return $session;
});
$app = new \Phalcon\Mvc\Micro($di);
// rest of code Not sure what happens exactly and why on previous version it was working correctly. It looks like start was called or not? |
Here we need hot fix rather than workaround as people cannot change their code base that easily. If the simplest scenario (steps to reproduce) does not work as expected, i.e. throwing a fatal error, that's bad for a release declared as stable (3.2.0) and must be fixed ASAP. |
But i don't know what workaround? For me it's working as it should be. In PHP you can't set Tbh even on php 7 and phalcon 3/3.1, your code won't work as expected - yea it would save to |
You provided a workaround - didn't you? #12918 (comment) I really don't see the point what you're trying to explain with PHP sessions etc. Yeah I like fatal error too - better fatal error than SEGFAULT. But the question is why this is broken and how to hot fix it. |
For me it's not broken, it works as it should be imho beacause you didn't start session so $_SESSION is unknown at this point. |
It wasn't really working - you could set value like that to $_SESSION but since you didn't started it anywhere its doing pretty much nothing in other request you can't access it. Just in 3.1.2 it wasn't working too as expected - you just didn't have any error at all. You would know that it wasn't working as expected when accessing this value from bag in other request. |
@stamster Actually we can check session status on |
What i mean - it's stupid to fix it to NOT throw fatal error or anything - because this code doesn't really work as it should be. Yea it will set $_SESSION value, but it won't do what you expect to do without Imho adding checks if sessions was started will introduce overhead - so it should stay as it is. Only i would consider one thing - throw this error on all versions or don't throw it. |
@sergeyklay If I'm able to find out root cause and not to trigger BC issues, for sure I'll do a PR. I believe this issue deserves label also. @Jurigag You simply try to ignore simple fact that even back with Phalcon v2.0.x this code was working w/o any issues, all until now with 3.2.0. And precisely - the bag is being populated with the data once it is set in the simplest example provided here, and it still does work on 3.1.2 on live API. |
@stamster but it WASN'T working without any issues - it wasn't working as exepected, like after refresh there wasn't really value set in I checked it on both phalcon 2 and 3 - without session_start you don't have really value set in $_SESSION obviously, so if there is exception right now - im fine with it. Yes it's internal stuff, but it's based on SESSION, if you didn't started session, then setting any data to persistent is pretty much out of point. You can use |
It's stupid to argue that your code is not working in phalcon 3.2 - because it's not working in 3.1 and 3 and 2 too really as expected(save value in |
Also to add - why this is 100% correct exception for me and it's actually feature - not a bug. If you do Imho the best will be in Phalcon 4 to remove session from |
Close in favor of #12921 |
Well @sjinks could at least answer if this superglobal detection is something which was added or it's just some mistaken code? https://github.com/phalcon/zephir/pull/1532/files#diff-91d00b5ec72fef64318f760cae59fbdaR116 im guessing that this is mainly thing making a difference, that we return failure here and previously there were success and that's why your code was "working"? |
Refs: #10530 |
For now, I've added this code snippet on a central location:
And now it does work as before 3.2.0. Even better solution. Kudos to @Jurigag for giving a hint for Registry class. use \Phalcon\Registry as RegistryBag;
// Overriding default functionality by simpler one, w/o need to re-factor code base
$di->setShared('persistent', function(){
return new RegistryBag();
}); |
You needed this to work persistent as it should anyway like start session(to have session variables available in other request). If you don't then Registry is exactly for you imho. This is why i was posting that you need to start session anyway and this is not really a bug, there was just change in zephir code to return failure on not recognized superglobal. |
You're just wrong big time on this one - that it wasn't working at all, even with previous Zephir / Phalcon. It was, and it's so easy to prove it, just install 3.1.2 and see for yourself on simplest example provided here - steps to reproduce. IDK who started session internally - it wasn't me for sure, was it Zephir or Phalcon internally - it doesn't really matter, but with |
I installed and it wasn't working - when accessing this variable in other request it wasn't there because session wasn't started. There were bug in zephir which was just allowing to use it like this. Now it's corrected. For example in php if you don't do |
Just do in one request: $di = new \Phalcon\Di\FactoryDefault();
$app = new \Phalcon\Mvc\Micro();
$app->get(
"/say/hello/{name}",
function ($name) {
echo "<h1>Hello! $name</h1>";
}
);
$app->persistent->auditID = 1; And in other: $di = new \Phalcon\Di\FactoryDefault();
$app = new \Phalcon\Mvc\Micro();
$app->get(
"/say/hello/{name}",
function ($name) {
echo "<h1>Hello! $name</h1>";
}
);
var_dump($app->persistent->auditID); You will have null returned. In latest zephir it was fixed to not allow like this. |
You're obviously missing the point while desperately trying to prove your points are right - technically. So one more time in case you have troubles to see it correctly:
That way system still works in a production, but instead you'll try to prove me wrong that I don't see stuff as I haven't actually started the Session. What has more value? Your tech. explanation or my 24/7 proven system? Anyway, thanks for a hint for |
But persistent is using There was only one issue - that zephir was allowing you to use persistent and save session variable without starting it, now it detects invalid superglobals(which |
Conclusion that something is used in a technically "wrong manner" does not disapprove the fact that it worked (and still does) as expected from app logic perspective. Case closed. |
Yea, and now it isn't, as it should be because session was not started and |
Expected and Actual Behavior
Now this is truly "the bug". Everything working fine on 3.1.2. From 3.2.0 entire app breaks with fatal error.
Details
3.2.0
)PHP 7.0.18
)0.9.8-6335775f25
)Everything working fine on 3.1.2. From 3.2.0 entire app breaks with fatal error.
The text was updated successfully, but these errors were encountered: