Skip to content
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

[BUG]: Session Stream Adapter GC throws an error #16713

Closed
satorumoriwaki opened this issue Mar 6, 2025 · 5 comments · Fixed by #16715
Closed

[BUG]: Session Stream Adapter GC throws an error #16713

satorumoriwaki opened this issue Mar 6, 2025 · 5 comments · Fixed by #16715
Assignees
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium

Comments

@satorumoriwaki
Copy link

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

@satorumoriwaki satorumoriwaki added bug A bug report status: unverified Unverified labels Mar 6, 2025
@raicabogdan
Copy link
Contributor

raicabogdan commented Mar 6, 2025

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.

@satorumoriwaki
Copy link
Author

@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;
});

@raicabogdan
Copy link
Contributor

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.

@niden niden self-assigned this Mar 7, 2025
@niden niden added status: medium Medium 5.0 The issues we want to solve in the 5.0 release and removed status: unverified Unverified labels Mar 7, 2025
@niden niden added this to Phalcon v5 Mar 7, 2025
@niden niden moved this to In Progress in Phalcon v5 Mar 7, 2025
@niden
Copy link
Member

niden commented Mar 7, 2025

Clearly the glob() method fails and returns false. This could be permissions.

Either way I am going to issue a fix for this shortly.

This was referenced Mar 7, 2025
@niden niden linked a pull request Mar 7, 2025 that will close this issue
5 tasks
@niden
Copy link
Member

niden commented Mar 7, 2025

Resolved in #16715

Thank you @raicabogdan and @satorumoriwaki

@niden niden closed this as completed Mar 7, 2025
@niden niden moved this from In Progress to Implemented in Phalcon v5 Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium
Projects
Status: Implemented
Development

Successfully merging a pull request may close this issue.

3 participants