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

PHP Deprecated: Calling session_set_save_handler() in PHP 8.4. #20140

Open
terabytesoftw opened this issue Mar 26, 2024 · 4 comments
Open

PHP Deprecated: Calling session_set_save_handler() in PHP 8.4. #20140

terabytesoftw opened this issue Mar 26, 2024 · 4 comments
Labels

Comments

@terabytesoftw
Copy link
Member

PHP Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in /home/runner/work/yii2/yii2/framework/web/Session.php on line 187

@rob006 @samdark @bizley

This is the last error we have left in PHP 8.4, which would be the best way to fix it.

@rob006
Copy link
Contributor

rob006 commented Mar 26, 2024

https://wiki.php.net/rfc/deprecate_functions_with_overloaded_signatures#session_set_save_handler

Suggested backward compatible alternative: code which calls session_set_save_handler() with 6 or more arguments should wrap the callbacks into a SessionHandlerInterface implementation.

@terabytesoftw
Copy link
Member Author

terabytesoftw commented Mar 27, 2024

class SessionHandlerInterface {
    /* Métodos */
    abstract public close(): bool
    abstract public destroy(string $session_id): bool
    abstract public gc(int $maxlifetime): int
    abstract public open(string $save_path, string $session_name): bool
    abstract public read(string $session_id): string
    abstract public write(string $session_id, string $session_data): bool
}

I will have to add these new methods, and call the old ones the new methods, is it the only way to not break bc?

@samdark
Copy link
Member

samdark commented Apr 2, 2024

Seems so.

@rob006
Copy link
Contributor

rob006 commented Apr 3, 2024

We could create a separate decorator class to avoid adding more methods to Session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants