From 60733eb5c900192cff775429aff669badb5fffc0 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Tue, 11 Feb 2014 12:32:54 +0100 Subject: [PATCH] Make Predis v0.8 compatible with HHVM 2.4.0. Since we cannot rely on the PHP version to detect the availability of socket_import_stream(), we switched to function_exists(). As an added bonus, using function_exists() is twice faster. --- lib/Predis/Connection/StreamConnection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Predis/Connection/StreamConnection.php b/lib/Predis/Connection/StreamConnection.php index a42788b2..79d0101a 100644 --- a/lib/Predis/Connection/StreamConnection.php +++ b/lib/Predis/Connection/StreamConnection.php @@ -104,7 +104,7 @@ class StreamConnection extends AbstractConnection stream_set_timeout($resource, $timeoutSeconds, $timeoutUSeconds); } - if (isset($parameters->tcp_nodelay) && version_compare(PHP_VERSION, '5.4.0') >= 0) { + if (isset($parameters->tcp_nodelay) && function_exists('socket_import_stream')) { $socket = socket_import_stream($resource); socket_set_option($socket, SOL_TCP, TCP_NODELAY, (int) $parameters->tcp_nodelay); }