-
-
Notifications
You must be signed in to change notification settings - Fork 993
Description
Describe the bug
Using scheme => 'tls' causes a Deprecated warning on PHP 8.4 due to stream_context_set_option() being called with 2 arguments in StreamFactory::tlsStreamInitializer(), even though this deprecation was supposedly fixed in #1503.
To Reproduce
Steps to reproduce the behavior:
- Create a simple Predis\Client instance using the tls scheme to connect to Azure Redis:
$client = new Predis\Client([
'scheme' => 'tls',
'host' => 'your.redis.host',
'port' => 10000,
'password' => 'your-password',
'ssl' => [
'verify_peer' => true,
'verify_peer_name' => true,
],
]);- Run the script on PHP 8.4
- See this warning:
Deprecated: Calling stream_context_set_option() with 2 arguments is deprecated
Expected behavior
No deprecation warning when using TLS. The method stream_context_set_options() should be used instead of the deprecated stream_context_set_option() (2-arg variant) in all connection paths, including the one triggered by scheme => 'tls'.
Versions:
Predis: 3.0.1
PHP: 8.4.
Redis Server: 7.4 - Azure Managed Redis
OS: Windows 11 / Ubuntu 22.04
Versions (please complete the following information):
- Predis: [e.g. 1.1.2]
- PHP [e.g. 8.0.0]
- Redis Server [e.g. 6.0.0]
- OS [e.g. Ubuntu 20.10]
Code sample
$client = new Predis\Client([
'scheme' => 'tls',
'host' => 'your.redis.host',
'port' => 10000,
'password' => 'your-password',
'ssl' => [
'verify_peer' => true,
'verify_peer_name' => true,
],
]);
$client->setex('key', 60, 'value');Additional context
The bug is located in Predis\Connection\Resource\StreamFactory::tlsStreamInitializer(). Even though the changelog mentions PHP 8.4 compatibility was addressed, the TLS-specific initializer still uses the deprecated call.