Skip to content

Commit

Permalink
abort if stream_socket_client() is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
tillkruss committed Nov 22, 2023
1 parent 25d5b1d commit 7751bd6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- Support rare PHP installations without `sockets` extension

## 2.5.0

- Require WordPress 4.6 or newer
Expand Down
8 changes: 8 additions & 0 deletions includes/class-predis.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class Predis {
* @return void
*/
public function connect( $read_timeout = null ) {
if ( ! function_exists( 'stream_socket_client' ) ) {
return;
}

// Load bundled Predis library.
if ( ! class_exists( '\Predis\Client' ) ) {
require_once WP_REDIS_PLUGIN_PATH . '/dependencies/predis/predis/autoload.php';
Expand Down Expand Up @@ -151,6 +155,10 @@ public function flush( $throw_exception = false ) {
}
}

if ( is_null( $this->redis ) ) {
return false;
}

if ( defined( 'WP_REDIS_CLUSTER' ) ) {
try {
foreach ( $this->redis->_masters() as $master ) {
Expand Down

0 comments on commit 7751bd6

Please sign in to comment.