[BUG]: Session Stream Adapter GC throws an error
Questions? Forum: https://phalcon.io/forum or Discord: https://phalcon.io/discord
Describe the bug
Phalcon\Session\Adapter\Stream->gc()
The argument is not initialized or iterable()
To Reproduce
Expected behavior
Screenshots
Details
file is not initialized as array.
https://github.com/phalcon/cphalcon/blob/master/phalcon/Session/Adapter/Stream.zep#L98
it is used as array in for loop.
https://github.com/phalcon/cphalcon/blob/master/phalcon/Session/Adapter/Stream.zep#L103
- Phalcon version: 5.8.0
- PHP Version: 8.3.10
- Operating System: Redhat Linux 9
- Installation type: dnf
- Zephir version (if any):
- Server: nginx
Additional context
Can you also include the code part of your session provider initialization in container?
I'm interested to know if you have set it up correctly and how you are using it.
@raicabogdan
Here are error messages.
The argument is not initialized or iterable()
#0 [internal function]: Phalcon\Session\Adapter\Stream->gc()
#1 [internal function]: session_start()
#2 /path/to/www/application/configs/config.production.php(379): Phalcon\Session\Manager->start()
#3 [internal function]: Closure->{closure}()
#4 [internal function]: Phalcon\Di\Service->resolve()
#5 [internal function]: Phalcon\Di\Di->get()
#6 [internal function]: Phalcon\Di\Di->getShared()
#7 /path/to/www/application/controllers/BaseController.php(184): Phalcon\Di\Injectable->__get()
#8 /path/to/www/application/controllers/BaseController.php(346): BaseController->getCart()
#9 /path/to/www/application/controllers/MeasuringDeviceController.php(217): BaseController->initialize()
#10 [internal function]: MeasuringDeviceController->initialize()
#11 [internal function]: Phalcon\Dispatcher\AbstractDispatcher->dispatch()
#12 /path/to/www/html/index.php(40): Phalcon\Mvc\Application->handle()
#13 {main}
Here is the part of the code for session.
use \Phalcon\Session\Manager as SessionManager;
use \Phalcon\Session\Adapter\Stream as SessionStream;
...
...
...
// session
$di->setShared('session', function()
{
$session = new SessionManager();
$files = new SessionStream();
$session->setAdapter($files);
$session->start();
return $session;
});
If you don't pass a proper savePath to the Stream() constructor
[
'savePath' => '/some/path'
]
you have to ensure the php ini value for session.save_path contains a valid directory. If the path is incorrect, the glob would return false and boolean is not iterable. Technically you should have received an exception there, if you wrap the initialization into a try/catch, you should see the issue.
Clearly the glob() method fails and returns false. This could be permissions.
Either way I am going to issue a fix for this shortly.
Resolved in https://github.com/phalcon/cphalcon/pull/16715
Thank you @raicabogdan and @satorumoriwaki