diff options
-rw-r--r-- | 1365.patch | 66 | ||||
-rw-r--r-- | REFLECTION | 32 | ||||
-rw-r--r-- | getSessionData.php | 22 | ||||
-rw-r--r-- | php-pecl-redis4.spec | 31 | ||||
-rw-r--r-- | regenerateSessionId.php | 84 | ||||
-rw-r--r-- | startSession.php | 41 |
6 files changed, 263 insertions, 13 deletions
diff --git a/1365.patch b/1365.patch new file mode 100644 index 0000000..b84586f --- /dev/null +++ b/1365.patch @@ -0,0 +1,66 @@ +From edab489323b587e414564b6417cbb15d7d1b90aa Mon Sep 17 00:00:00 2001 +From: Remi Collet <remi@remirepo.net> +Date: Fri, 8 Jun 2018 10:46:04 +0200 +Subject: [PATCH] use PHP_BINARY instead of php and allow override + +--- + tests/RedisTest.php | 10 ++++++---- + tests/TestRedis.php | 2 ++ + 2 files changed, 8 insertions(+), 4 deletions(-) + +diff --git a/tests/RedisTest.php b/tests/RedisTest.php +index ff0b7537..efb25f2e 100644 +--- a/tests/RedisTest.php ++++ b/tests/RedisTest.php +@@ -5550,6 +5550,7 @@ private function startSessionProcess($sessionId, $sleepTime, $background, $maxEx + $this->markTestSkipped(); + return true; + } else { ++ $phpcmd = (getenv("PHPCMD") ?: PHP_BINARY); + $commandParameters = array($this->getFullHostPath(), $this->sessionSaveHandler, $sessionId, $sleepTime, $maxExecutionTime, $lock_retries, $lock_expires, $sessionData, $sessionLifetime); + if ($locking_enabled) { + $commandParameters[] = '1'; +@@ -5560,9 +5561,8 @@ private function startSessionProcess($sessionId, $sleepTime, $background, $maxEx + } + $commandParameters = array_map('escapeshellarg', $commandParameters); + +- $command = 'php ' . __DIR__ . '/startSession.php ' . implode(' ', $commandParameters); ++ $command = "$phpcmd " . __DIR__ . '/startSession.php ' . implode(' ', $commandParameters); + $command .= $background ? ' 2>/dev/null > /dev/null &' : ' 2>&1'; +- + exec($command, $output); + return ($background || (count($output) == 1 && $output[0] == 'SUCCESS')) ? true : false; + } +@@ -5576,7 +5576,8 @@ private function startSessionProcess($sessionId, $sleepTime, $background, $maxEx + */ + private function getSessionData($sessionId, $sessionLifetime = 1440) + { +- $command = 'php ' . __DIR__ . '/getSessionData.php ' . escapeshellarg($this->getFullHostPath()) . ' ' . $this->sessionSaveHandler . ' ' . escapeshellarg($sessionId) . ' ' . escapeshellarg($sessionLifetime); ++ $phpcmd = (getenv("PHPCMD") ?: PHP_BINARY); ++ $command = "$phpcmd " . __DIR__ . '/getSessionData.php ' . escapeshellarg($this->getFullHostPath()) . ' ' . $this->sessionSaveHandler . ' ' . escapeshellarg($sessionId) . ' ' . escapeshellarg($sessionLifetime); + exec($command, $output); + + return $output[0]; +@@ -5594,7 +5595,8 @@ private function regenerateSessionId($sessionId, $locking = false, $destroyPrevi + { + $args = array_map('escapeshellarg', array($sessionId, $locking, $destroyPrevious, $sessionProxy)); + +- $command = 'php --no-php-ini --define extension=igbinary.so --define extension=' . __DIR__ . '/../modules/redis.so ' . __DIR__ . '/regenerateSessionId.php ' . escapeshellarg($this->getFullHostPath()) . ' ' . $this->sessionSaveHandler . ' ' . implode(' ', $args); ++ $phpcmd = (getenv("PHPCMD") ?: PHP_BINARY . ' --no-php-ini --define extension=igbinary.so --define extension=' . __DIR__ . '/../modules/redis.so'); ++ $command = "$phpcmd " . __DIR__ . '/regenerateSessionId.php ' . escapeshellarg($this->getFullHostPath()) . ' ' . $this->sessionSaveHandler . ' ' . implode(' ', $args); + + exec($command, $output); + +diff --git a/tests/TestRedis.php b/tests/TestRedis.php +index 4348c7d8..7107669e 100644 +--- a/tests/TestRedis.php ++++ b/tests/TestRedis.php +@@ -35,6 +35,8 @@ + /* Let the user know this can take a bit of time */ + echo "Note: these tests might take up to a minute. Don't worry :-)\n"; + echo "Using PHP version " . PHP_VERSION . " (" . (PHP_INT_SIZE*8) . " bits)\n"; ++$phpcmd = (getenv("PHPCMD") ?: PHP_BINARY); ++echo "Using PHP command: $phpcmd\n"; + + /* Depending on the classes being tested, run our tests on it */ + echo "Testing class "; @@ -1,4 +1,4 @@ -Extension [ <persistent> extension #191 redis version 4.0.2 ] { +Extension [ <persistent> extension #192 redis version 4.1.0RC1 ] { - Dependencies { Dependency [ igbinary (Required) ] @@ -53,6 +53,18 @@ Extension [ <persistent> extension #191 redis version 4.0.2 ] { Entry [ redis.clusters.timeout <ALL> ] Current = '' } + Entry [ redis.session.locking_enabled <ALL> ] + Current = '' + } + Entry [ redis.session.lock_expire <ALL> ] + Current = '' + } + Entry [ redis.session.lock_retries <ALL> ] + Current = '' + } + Entry [ redis.session.lock_wait_time <ALL> ] + Current = '' + } } - Classes [5] { @@ -353,13 +365,15 @@ Extension [ <persistent> extension #191 redis version 4.0.2 ] { Method [ <internal:redis> public method flushAll ] { - - Parameters [0] { + - Parameters [1] { + Parameter #0 [ <optional> $async ] } } Method [ <internal:redis> public method flushDB ] { - - Parameters [0] { + - Parameters [1] { + Parameter #0 [ <optional> $async ] } } @@ -1933,13 +1947,15 @@ Extension [ <persistent> extension #191 redis version 4.0.2 ] { Method [ <internal:redis> public method flushall ] { - - Parameters [0] { + - Parameters [1] { + Parameter #0 [ <optional> $async ] } } Method [ <internal:redis> public method flushdb ] { - - Parameters [0] { + - Parameters [1] { + Parameter #0 [ <optional> $async ] } } @@ -2348,15 +2364,17 @@ Extension [ <persistent> extension #191 redis version 4.0.2 ] { Method [ <internal:redis> public method flushall ] { - - Parameters [1] { + - Parameters [2] { Parameter #0 [ <required> $key_or_address ] + Parameter #1 [ <optional> $async ] } } Method [ <internal:redis> public method flushdb ] { - - Parameters [1] { + - Parameters [2] { Parameter #0 [ <required> $key_or_address ] + Parameter #1 [ <optional> $async ] } } diff --git a/getSessionData.php b/getSessionData.php new file mode 100644 index 0000000..d49256c --- /dev/null +++ b/getSessionData.php @@ -0,0 +1,22 @@ +<?php +error_reporting(E_ERROR | E_WARNING); + +$redisHost = $argv[1]; +$saveHandler = $argv[2]; +$sessionId = $argv[3]; +$sessionLifetime = $argv[4]; + +if (empty($redisHost)) { + $redisHost = 'tcp://localhost:6379'; +} + +ini_set('session.save_handler', $saveHandler); +ini_set('session.save_path', $redisHost); +ini_set('session.gc_maxlifetime', $sessionLifetime); + +session_id($sessionId); +if (!session_start()) { + echo "session_start() was nut successful"; +} else { + echo isset($_SESSION['redis_test']) ? $_SESSION['redis_test'] : 'Key redis_test not found'; +} diff --git a/php-pecl-redis4.spec b/php-pecl-redis4.spec index 4370def..c91b62d 100644 --- a/php-pecl-redis4.spec +++ b/php-pecl-redis4.spec @@ -28,8 +28,8 @@ # after 40-igbinary %global ini_name 50-%{pecl_name}.ini %endif -%global upstream_version 4.0.2 -#global upstream_prever RC2 +%global upstream_version 4.1.0 +%global upstream_prever RC1 Summary: Extension for communicating with the Redis key-value store Name: %{?sub_prefix}php-pecl-redis4 @@ -39,6 +39,14 @@ Source0: http://pecl.php.net/get/%{pecl_name}-%{upstream_version}%{?upstre License: PHP URL: http://pecl.php.net/package/redis +# See https://github.com/phpredis/phpredis/issues/1364 +Source1: https://raw.githubusercontent.com/phpredis/phpredis/develop/tests/regenerateSessionId.php +Source2: https://raw.githubusercontent.com/phpredis/phpredis/develop/tests/getSessionData.php +Source3: https://raw.githubusercontent.com/phpredis/phpredis/develop/tests/startSession.php + +# See https://github.com/phpredis/phpredis/pull/1365 +Patch0: 1365.patch + BuildRequires: %{?dtsprefix}gcc BuildRequires: %{?scl_prefix}php-devel BuildRequires: %{?scl_prefix}php-pear @@ -123,6 +131,8 @@ sed -e 's/role="test"/role="src"/' \ -i package.xml cd NTS +cp %{SOURCE1} %{SOURCE2} %{SOURCE3} tests/ +%patch0 -p1 -b .pr1365 # Use system library rm -r liblzf @@ -172,6 +182,10 @@ extension = %{pecl_name}.so ;redis.clusters.read_timeout = '' ;redis.clusters.seeds = '' ;redis.clusters.timeout = '' +;redis.session.locking_enabled = '' +;redis.session.lock_expire = '' +;redis.session.lock_retries = '' +;redis.session.lock_wait_time = '' EOF @@ -263,16 +277,16 @@ port=$(%{__php} -r 'echo 9000 + PHP_MAJOR_VERSION*100 + PHP_MINOR_VERSION*10 + P --dir $PWD/data \ --pidfile $pidfile -sed -e "s/6379/$port/" -i RedisTest.php +sed -e "s/6379/$port/" -i *.php # Run the test Suite ret=0 -%{__php} --no-php-ini \ +export PHPCMD="%{__php} --no-php-ini \ %if %{with_igbin} --define extension=igbinary.so \ %endif - --define extension=%{buildroot}%{php_extdir}/%{pecl_name}.so \ - TestRedis.php || ret=1 + --define extension=%{buildroot}%{php_extdir}/%{pecl_name}.so" +$PHPCMD TestRedis.php || ret=1 # Cleanup if [ -f $pidfile ]; then @@ -323,6 +337,11 @@ fi %changelog * Wed Apr 25 2018 Remi Collet <remi@remirepo.net> - 4.0.2-1 - update to 4.0.2 +- open https://github.com/phpredis/phpredis/pull/1365 + use PHP_BINARY instead of php and allow override +- report https://github.com/phpredis/phpredis/issues/1364 + missing files in pecl archive +- add new redis.session.lock* options in provided configuration * Wed Apr 18 2018 Remi Collet <remi@remirepo.net> - 4.0.1-1 - update to 4.0.1 diff --git a/regenerateSessionId.php b/regenerateSessionId.php new file mode 100644 index 0000000..f0e4c4e --- /dev/null +++ b/regenerateSessionId.php @@ -0,0 +1,84 @@ +<?php +error_reporting(E_ERROR | E_WARNING); + +$redisHost = $argv[1]; +$saveHandler = $argv[2]; +$sessionId = $argv[3]; +$locking = !!$argv[4]; +$destroyPrevious = !!$argv[5]; +$sessionProxy = !!$argv[6]; + +if (empty($redisHost)) { + $redisHost = 'tcp://localhost:6379'; +} + +ini_set('session.save_handler', $saveHandler); +ini_set('session.save_path', $redisHost); + +if ($locking) { + ini_set('redis.session.locking_enabled', true); +} + +if (interface_exists('SessionHandlerInterface')) { + class TestHandler implements SessionHandlerInterface + { + /** + * @var SessionHandler + */ + private $handler; + + public function __construct() + { + $this->handler = new SessionHandler(); + } + + public function close() + { + return $this->handler->close(); + } + + public function destroy($session_id) + { + return $this->handler->destroy($session_id); + } + + public function gc($maxlifetime) + { + return $this->handler->gc($maxlifetime); + } + + public function open($save_path, $name) + { + return $this->handler->open($save_path, $name); + } + + public function read($session_id) + { + return $this->handler->read($session_id); + } + + public function write($session_id, $session_data) + { + return $this->handler->write($session_id, $session_data); + } + } +} + +if ($sessionProxy) { + $handler = new TestHandler(); + session_set_save_handler($handler); +} + +session_id($sessionId); +if (!session_start()) { + $result = "FAILED: session_start()"; +} +elseif (!session_regenerate_id($destroyPrevious)) { + $result = "FAILED: session_regenerate_id()"; +} +else { + $result = session_id(); +} +session_write_close(); +echo $result; + diff --git a/startSession.php b/startSession.php new file mode 100644 index 0000000..2149da6 --- /dev/null +++ b/startSession.php @@ -0,0 +1,41 @@ +<?php +error_reporting(E_ERROR | E_WARNING); + +$redisHost = $argv[1]; +$saveHandler = $argv[2]; +$sessionId = $argv[3]; +$sleepTime = $argv[4]; +$maxExecutionTime = $argv[5]; +$lock_retries = $argv[6]; +$lock_expire = $argv[7]; +$sessionData = $argv[8]; +$sessionLifetime = $argv[9]; + +if (empty($redisHost)) { + $redisHost = 'tcp://localhost:6379'; +} + +ini_set('session.save_handler', $saveHandler); +ini_set('session.save_path', $redisHost); +ini_set('max_execution_time', $maxExecutionTime); +ini_set('redis.session.lock_retries', $lock_retries); +ini_set('redis.session.lock_expire', $lock_expire); +ini_set('session.gc_maxlifetime', $sessionLifetime); + +if (isset($argv[8])) { + ini_set('redis.session.locking_enabled', $argv[10]); +} + +if (isset($argv[9])) { + ini_set('redis.session.lock_wait_time', $argv[11]); +} + +session_id($sessionId); +$sessionStartSuccessful = session_start(); +sleep($sleepTime); +if (!empty($sessionData)) { + $_SESSION['redis_test'] = $sessionData; +} +session_write_close(); + +echo $sessionStartSuccessful ? 'SUCCESS' : 'FAILURE';
\ No newline at end of file |