summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2024-09-16 09:07:43 +0200
committerRemi Collet <remi@php.net>2024-09-16 09:07:43 +0200
commit5b1e772c6b5e68509728752a7b963a89dc03baf5 (patch)
tree1fadbf7fc942f0e8b836b6b93206d66743ad6f26
parentce66a541e21323ade4904a8697a06158cd099678 (diff)
update to 6.1.0RC1
open https://github.com/phpredis/phpredis/pull/2532 missing file drop support for PHP < 7.4
-rw-r--r--PHPINFO4
-rw-r--r--REFLECTION116
-rw-r--r--SessionHelpers.php353
-rw-r--r--php-pecl-redis6.spec30
4 files changed, 451 insertions, 52 deletions
diff --git a/PHPINFO b/PHPINFO
index 7f67616..35333b6 100644
--- a/PHPINFO
+++ b/PHPINFO
@@ -2,7 +2,7 @@
redis
Redis Support => enabled
-Redis Version => 6.0.2
+Redis Version => 6.1.0RC1
Redis Sentinel Version => 1.0
Available serializers => php, json, igbinary, msgpack
Available compression => lzf, zstd, lz4
@@ -40,3 +40,5 @@ redis.session.lock_expire => 0 => 0
redis.session.lock_retries => 100 => 100
redis.session.lock_wait_time => 20000 => 20000
redis.session.early_refresh => 0 => 0
+redis.session.compression => none => none
+redis.session.compression_level => 3 => 3
diff --git a/REFLECTION b/REFLECTION
index a69a648..74d6e30 100644
--- a/REFLECTION
+++ b/REFLECTION
@@ -1,4 +1,4 @@
-Extension [ <persistent> extension #122 redis version 6.0.2 ] {
+Extension [ <persistent> extension #107 redis version 6.1.0RC1 ] {
- Dependencies {
Dependency [ igbinary (Required) ]
@@ -104,12 +104,18 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
Entry [ redis.session.early_refresh <ALL> ]
Current = '0'
}
+ Entry [ redis.session.compression <ALL> ]
+ Current = 'none'
+ }
+ Entry [ redis.session.compression_level <ALL> ]
+ Current = '3'
+ }
}
- Classes [6] {
Class [ <internal:redis> class Redis ] {
- - Constants [49] {
+ - Constants [50] {
Constant [ public int REDIS_NOT_FOUND ] { 0 }
Constant [ public int REDIS_STRING ] { 1 }
Constant [ public int REDIS_SET ] { 2 }
@@ -137,6 +143,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
Constant [ public int COMPRESSION_LZF ] { 1 }
Constant [ public int COMPRESSION_ZSTD ] { 2 }
Constant [ public int COMPRESSION_ZSTD_DEFAULT ] { 3 }
+ Constant [ public int COMPRESSION_ZSTD_MIN ] { -131072 }
Constant [ public int COMPRESSION_ZSTD_MAX ] { 22 }
Constant [ public int COMPRESSION_LZ4 ] { 3 }
Constant [ public int OPT_SCAN ] { 4 }
@@ -170,7 +177,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Properties [0] {
}
- - Methods [254] {
+ - Methods [255] {
Method [ <internal:redis, ctor> public method __construct ] {
- Parameters [1] {
@@ -280,6 +287,16 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Return [ Redis|bool ]
}
+ Method [ <internal:redis> public method waitaof ] {
+
+ - Parameters [3] {
+ Parameter #0 [ <required> int $numlocal ]
+ Parameter #1 [ <required> int $numreplicas ]
+ Parameter #2 [ <required> int $timeout ]
+ }
+ - Return [ Redis|array|false ]
+ }
+
Method [ <internal:redis> public method bitcount ] {
- Parameters [4] {
@@ -535,7 +552,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [1] {
Parameter #0 [ <required> string $key ]
}
- - Return [ Redis|string ]
+ - Return [ Redis|string|false ]
}
Method [ <internal:redis> public method echo ] {
@@ -1055,15 +1072,14 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
Parameter #0 [ <required> string $key ]
Parameter #1 [ <optional> ?array $options = null ]
}
- - Return [ Redis|array|string ]
+ - Return [ Redis|array|string|false ]
}
Method [ <internal:redis> public method hSet ] {
- - Parameters [3] {
+ - Parameters [2] {
Parameter #0 [ <required> string $key ]
- Parameter #1 [ <required> string $member ]
- Parameter #2 [ <required> mixed $value ]
+ Parameter #1 [ <optional> mixed ...$fields_and_vals ]
}
- Return [ Redis|int|false ]
}
@@ -1073,7 +1089,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [3] {
Parameter #0 [ <required> string $key ]
Parameter #1 [ <required> string $field ]
- Parameter #2 [ <required> string $value ]
+ Parameter #2 [ <required> mixed $value ]
}
- Return [ Redis|bool ]
}
@@ -1099,7 +1115,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [4] {
Parameter #0 [ <required> string $key ]
- Parameter #1 [ <required> ?int &$iterator ]
+ Parameter #1 [ <required> string|int|null &$iterator ]
Parameter #2 [ <optional> ?string $pattern = null ]
Parameter #3 [ <optional> int $count = 0 ]
}
@@ -1312,7 +1328,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [1] {
Parameter #0 [ <required> array $keys ]
}
- - Return [ Redis|array ]
+ - Return [ Redis|array|false ]
}
Method [ <internal:redis> public method migrate ] {
@@ -1721,7 +1737,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
Parameter #0 [ <required> string $key ]
Parameter #1 [ <optional> int $count = 0 ]
}
- - Return [ Redis|array|string|false ]
+ - Return [ mixed ]
}
Method [ <internal:redis> public method sUnion ] {
@@ -1753,7 +1769,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
Method [ <internal:redis> public method scan ] {
- Parameters [4] {
- Parameter #0 [ <required> ?int &$iterator ]
+ Parameter #0 [ <required> string|int|null &$iterator ]
Parameter #1 [ <optional> ?string $pattern = null ]
Parameter #2 [ <optional> int $count = 0 ]
Parameter #3 [ <optional> ?string $type = null ]
@@ -1972,7 +1988,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [4] {
Parameter #0 [ <required> string $key ]
- Parameter #1 [ <required> ?int &$iterator ]
+ Parameter #1 [ <required> string|int|null &$iterator ]
Parameter #2 [ <optional> ?string $pattern = null ]
Parameter #3 [ <optional> int $count = 0 ]
}
@@ -2269,8 +2285,8 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [3] {
Parameter #0 [ <required> string $key ]
- Parameter #1 [ <required> string $start ]
- Parameter #2 [ <required> string $end ]
+ Parameter #1 [ <required> string|int $start ]
+ Parameter #2 [ <required> string|int $end ]
}
- Return [ Redis|int|false ]
}
@@ -2531,7 +2547,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [4] {
Parameter #0 [ <required> string $key ]
- Parameter #1 [ <required> ?int &$iterator ]
+ Parameter #1 [ <required> string|int|null &$iterator ]
Parameter #2 [ <optional> ?string $pattern = null ]
Parameter #3 [ <optional> int $count = 0 ]
}
@@ -2672,7 +2688,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [0] {
}
- - Return [ ?bool ]
+ - Return [ array|bool|null ]
}
Method [ <internal:redis> public method flushall ] {
@@ -2701,7 +2717,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [4] {
Parameter #0 [ <required> string $key ]
- Parameter #1 [ <required> ?int &$iterator ]
+ Parameter #1 [ <required> string|int|null &$iterator ]
Parameter #2 [ <optional> ?string $pattern = null ]
Parameter #3 [ <optional> int $count = 0 ]
}
@@ -2765,7 +2781,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
Method [ <internal:redis> public method scan ] {
- Parameters [4] {
- Parameter #0 [ <required> ?int &$iterator ]
+ Parameter #0 [ <required> string|int|null &$iterator ]
Parameter #1 [ <required> string $node ]
Parameter #2 [ <optional> ?string $pattern = null ]
Parameter #3 [ <optional> int $count = 0 ]
@@ -2794,7 +2810,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [4] {
Parameter #0 [ <required> string $key ]
- Parameter #1 [ <required> ?int &$iterator ]
+ Parameter #1 [ <required> string|int|null &$iterator ]
Parameter #2 [ <optional> ?string $pattern = null ]
Parameter #3 [ <optional> int $count = 0 ]
}
@@ -2821,7 +2837,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [4] {
Parameter #0 [ <required> string $key ]
- Parameter #1 [ <required> ?int &$iterator ]
+ Parameter #1 [ <required> string|int|null &$iterator ]
Parameter #2 [ <optional> ?string $pattern = null ]
Parameter #3 [ <optional> int $count = 0 ]
}
@@ -2849,7 +2865,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Properties [0] {
}
- - Methods [222] {
+ - Methods [224] {
Method [ <internal:redis, ctor> public method __construct ] {
- Parameters [7] {
@@ -2960,6 +2976,17 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Return [ RedisCluster|bool ]
}
+ Method [ <internal:redis> public method waitaof ] {
+
+ - Parameters [4] {
+ Parameter #0 [ <required> array|string $key_or_address ]
+ Parameter #1 [ <required> int $numlocal ]
+ Parameter #2 [ <required> int $numreplicas ]
+ Parameter #3 [ <required> int $timeout ]
+ }
+ - Return [ RedisCluster|array|false ]
+ }
+
Method [ <internal:redis> public method bgsave ] {
- Parameters [1] {
@@ -3129,7 +3156,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [3] {
Parameter #0 [ <required> array|string $key_or_address ]
Parameter #1 [ <required> string $subcommand ]
- Parameter #2 [ <optional> ?string $arg = NULL ]
+ Parameter #2 [ <optional> ?string $arg = null ]
}
- Return [ array|string|bool ]
}
@@ -3317,7 +3344,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [3] {
Parameter #0 [ <required> string $key ]
Parameter #1 [ <required> int $timeout ]
- Parameter #2 [ <optional> ?string $mode = NULL ]
+ Parameter #2 [ <optional> ?string $mode = null ]
}
- Return [ RedisCluster|bool ]
}
@@ -3327,7 +3354,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [3] {
Parameter #0 [ <required> string $key ]
Parameter #1 [ <required> int $timestamp ]
- Parameter #2 [ <optional> ?string $mode = NULL ]
+ Parameter #2 [ <optional> ?string $mode = null ]
}
- Return [ RedisCluster|bool ]
}
@@ -3492,6 +3519,15 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Return [ mixed ]
}
+ Method [ <internal:redis> public method getex ] {
+
+ - Parameters [2] {
+ Parameter #0 [ <required> string $key ]
+ Parameter #1 [ <optional> array $options = [] ]
+ }
+ - Return [ RedisCluster|string|false ]
+ }
+
Method [ <internal:redis> public method getbit ] {
- Parameters [2] {
@@ -3538,7 +3574,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [3] {
Parameter #0 [ <required> string $key1 ]
Parameter #1 [ <required> string $key2 ]
- Parameter #2 [ <optional> ?array $options = NULL ]
+ Parameter #2 [ <optional> ?array $options = null ]
}
- Return [ RedisCluster|array|string|int|false ]
}
@@ -3660,7 +3696,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [4] {
Parameter #0 [ <required> string $key ]
- Parameter #1 [ <required> ?int &$iterator ]
+ Parameter #1 [ <required> string|int|null &$iterator ]
Parameter #2 [ <optional> ?string $pattern = null ]
Parameter #3 [ <optional> int $count = 0 ]
}
@@ -3934,7 +3970,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [3] {
Parameter #0 [ <required> string $key ]
Parameter #1 [ <required> int $timeout ]
- Parameter #2 [ <optional> ?string $mode = NULL ]
+ Parameter #2 [ <optional> ?string $mode = null ]
}
- Return [ RedisCluster|bool ]
}
@@ -3944,7 +3980,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [3] {
Parameter #0 [ <required> string $key ]
Parameter #1 [ <required> int $timestamp ]
- Parameter #2 [ <optional> ?string $mode = NULL ]
+ Parameter #2 [ <optional> ?string $mode = null ]
}
- Return [ RedisCluster|bool ]
}
@@ -3979,7 +4015,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [2] {
Parameter #0 [ <required> array|string $key_or_address ]
- Parameter #1 [ <optional> ?string $message = NULL ]
+ Parameter #1 [ <optional> ?string $message = null ]
}
- Return [ mixed ]
}
@@ -4017,7 +4053,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
Parameter #0 [ <required> string $channel ]
Parameter #1 [ <required> string $message ]
}
- - Return [ RedisCluster|bool ]
+ - Return [ RedisCluster|int|bool ]
}
Method [ <internal:redis> public method pubsub ] {
@@ -4080,7 +4116,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
Parameter #0 [ <required> string $key ]
Parameter #1 [ <required> int $timeout ]
Parameter #2 [ <required> string $value ]
- Parameter #3 [ <optional> ?array $options = NULL ]
+ Parameter #3 [ <optional> ?array $options = null ]
}
- Return [ RedisCluster|bool ]
}
@@ -4159,7 +4195,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
Method [ <internal:redis> public method scan ] {
- Parameters [4] {
- Parameter #0 [ <required> ?int &$iterator ]
+ Parameter #0 [ <required> string|int|null &$iterator ]
Parameter #1 [ <required> array|string $key_or_address ]
Parameter #2 [ <optional> ?string $pattern = null ]
Parameter #3 [ <optional> int $count = 0 ]
@@ -4338,7 +4374,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [2] {
Parameter #0 [ <required> string $key ]
- Parameter #1 [ <optional> ?array $options = NULL ]
+ Parameter #1 [ <optional> ?array $options = null ]
}
- Return [ RedisCluster|array|string|int|bool ]
}
@@ -4347,7 +4383,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [2] {
Parameter #0 [ <required> string $key ]
- Parameter #1 [ <optional> ?array $options = NULL ]
+ Parameter #1 [ <optional> ?array $options = null ]
}
- Return [ RedisCluster|array|string|int|bool ]
}
@@ -4384,7 +4420,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [4] {
Parameter #0 [ <required> string $key ]
- Parameter #1 [ <required> ?int &$iterator ]
+ Parameter #1 [ <required> string|int|null &$iterator ]
Parameter #2 [ <optional> ?string $pattern = null ]
Parameter #3 [ <optional> int $count = 0 ]
}
@@ -4879,7 +4915,7 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [4] {
Parameter #0 [ <required> string $key ]
- Parameter #1 [ <required> ?int &$iterator ]
+ Parameter #1 [ <required> string|int|null &$iterator ]
Parameter #2 [ <optional> ?string $pattern = null ]
Parameter #3 [ <optional> int $count = 0 ]
}
@@ -4910,8 +4946,8 @@ Extension [ <persistent> extension #122 redis version 6.0.2 ] {
- Parameters [4] {
Parameter #0 [ <required> string $dst ]
Parameter #1 [ <required> array $keys ]
- Parameter #2 [ <optional> ?array $weights = NULL ]
- Parameter #3 [ <optional> ?string $aggregate = NULL ]
+ Parameter #2 [ <optional> ?array $weights = null ]
+ Parameter #3 [ <optional> ?string $aggregate = null ]
}
- Return [ RedisCluster|int|false ]
}
diff --git a/SessionHelpers.php b/SessionHelpers.php
new file mode 100644
index 0000000..90ae73b
--- /dev/null
+++ b/SessionHelpers.php
@@ -0,0 +1,353 @@
+<?php
+
+namespace SessionHelpers;
+
+class PhpSpawner {
+ protected static function appendPhpArgs(string $php): string {
+ $modules = shell_exec("$php --no-php-ini -m");
+
+ /* Determine if we need to specifically add extensions */
+ $extensions = array_filter(
+ ['igbinary', 'msgpack', 'json', 'redis'],
+ function ($module) use ($modules) {
+ return strpos($modules, $module) === false;
+ }
+ );
+
+ /* If any are needed add them to the command */
+ if ($extensions) {
+ $php .= ' --no-php-ini';
+ foreach ($extensions as $extension) {
+ /* We want to use the locally built redis extension */
+ if ($extension == 'redis') {
+ $path = dirname(__DIR__) . '/modules/redis';
+ if (is_file("{$path}.so"))
+ $extension = $path;
+ }
+
+ $php .= " -dextension=$extension.so";
+ }
+ }
+
+ return $php;
+ }
+
+ /**
+ * Return command to launch PHP with built extension enabled
+ * taking care of environment (TEST_PHP_EXECUTABLE and TEST_PHP_ARGS)
+ *
+ * @param string $script
+ *
+ * @return string
+ */
+ public static function cmd(string $script): string {
+ static $cmd = NULL;
+
+ if ( ! $cmd) {
+ $cmd = getenv('TEST_PHP_EXECUTABLE') ?: PHP_BINARY;
+
+ if ($test_args = getenv('TEST_PHP_ARGS')) {
+ $cmd .= ' ' . $test_args;
+ } else {
+ $cmd = self::appendPhpArgs($cmd);
+ }
+ }
+
+ return $cmd . ' ' . __DIR__ . '/' . $script . ' ';
+ }
+}
+
+class Runner {
+ const start_script = 'startSession.php';
+ const regenerate_id_script = 'regenerateSessionId.php';
+ const get_data_script = 'getSessionData.php';
+
+ private $required = ['host', 'handler', 'id'];
+
+ private $args = [
+ 'handler' => null,
+ 'save-path' => null,
+ 'id' => null,
+ 'sleep' => 0,
+ 'max-execution-time' => 300,
+ 'locking-enabled' => true,
+ 'lock-wait-time' => null,
+ 'lock-retries' => -1,
+ 'lock-expires' => 0,
+ 'data' => '',
+ 'lifetime' => 1440,
+ 'compression' => 'none',
+ ];
+
+ private $prefix = NULL;
+ private $output_file;
+ private $exit_code = -1;
+ private $cmd = NULL;
+ private $pid;
+ private $output;
+
+ public function __construct() {
+ $this->args['id'] = $this->createId();
+ }
+
+ public function getExitCode(): int {
+ return $this->exit_code;
+ }
+
+ public function getCmd(): ?string {
+ return $this->cmd;
+ }
+
+ public function getId(): ?string {
+ return $this->args['id'];
+ }
+
+ public function prefix(string $prefix): self {
+ $this->prefix = $prefix;
+ return $this;
+ }
+
+ public function getSessionKey(): string {
+ return $this->prefix . $this->getId();
+ }
+
+ public function getSessionLockKey(): string {
+ return $this->getSessionKey() . '_LOCK';
+ }
+
+ protected function set($setting, $v): self {
+ $this->args[$setting] = $v;
+ return $this;
+ }
+
+ public function handler(string $handler): self {
+ return $this->set('handler', $handler);
+ }
+
+ public function savePath(string $path): self {
+ return $this->set('save-path', $path);
+ }
+
+ public function id(string $id): self {
+ return $this->set('id', $id);
+ }
+
+ public function sleep(int $sleep): self {
+ return $this->set('sleep', $sleep);
+ }
+
+ public function maxExecutionTime(int $time): self {
+ return $this->set('max-execution-time', $time);
+ }
+
+ public function lockingEnabled(bool $enabled): self {
+ return $this->set('locking-enabled', $enabled);
+ }
+
+ public function lockWaitTime(int $time): self {
+ return $this->set('lock-wait-time', $time);
+ }
+
+ public function lockRetries(int $retries): self {
+ return $this->set('lock-retries', $retries);
+ }
+
+ public function lockExpires(int $expires): self {
+ return $this->set('lock-expires', $expires);
+ }
+
+ public function data(string $data): self {
+ return $this->set('data', $data);
+ }
+
+ public function lifetime(int $lifetime): self {
+ return $this->set('lifetime', $lifetime);
+ }
+
+ public function compression(string $compression): self {
+ return $this->set('compression', $compression);
+ }
+
+ protected function validateArgs(array $required) {
+ foreach ($required as $req) {
+ if ( ! isset($this->args[$req]) || $this->args[$req] === null)
+ throw new \Exception("Command requires '$req' arg");
+ }
+ }
+
+ private function createId(): string {
+ if (function_exists('session_create_id'))
+ return session_create_id();
+
+ return uniqid();
+ }
+
+ private function getTmpFileName() {
+ return '/tmp/sessiontmp.txt';
+ return tempnam(sys_get_temp_dir(), 'session');
+ }
+
+ /*
+ * @param $client Redis client
+ * @param string $max_wait_sec
+ *
+ * Sometimes we want to block until a session lock has been detected
+ * This is better and faster than arbitrarily sleeping. If we don't
+ * detect the session key within the specified maximum number of
+ * seconds, the function returns failure.
+ *
+ * @return bool
+ */
+ public function waitForLockKey($redis, $max_wait_sec) {
+ $now = microtime(true);
+
+ do {
+ if ($redis->exists($this->getSessionLockKey()))
+ return true;
+ usleep(10000);
+ } while (microtime(true) <= $now + $max_wait_sec);
+
+ return false;
+ }
+
+ private function appendCmdArgs(array $args): string {
+ $append = [];
+
+ foreach ($args as $arg => $val) {
+ if ( ! $val)
+ continue;
+
+ if (is_string($val))
+ $val = escapeshellarg($val);
+
+ $append[] = "--$arg";
+ $append[] = $val;
+ }
+
+ return implode(' ', $append);
+ }
+
+ private function buildPhpCmd(string $script, array $args): string {
+ return PhpSpawner::cmd($script) . ' ' . $this->appendCmdArgs($args);
+ }
+
+ private function startSessionCmd(): string {
+ return $this->buildPhpCmd(self::start_script, $this->args);
+ }
+
+ public function output(?int $timeout = NULL): ?string {
+ if ($this->output) {
+ var_dump("early return");
+ return $this->output;
+ }
+
+ if ( ! $this->output_file || ! $this->pid) {
+ throw new \Exception("Process was not started in the background");
+ }
+
+ $st = microtime(true);
+
+ do {
+ if (pcntl_waitpid($this->pid, $exit_code, WNOHANG) == 0)
+ break;
+ usleep(100000);
+ } while ((microtime(true) - $st) < $timeout);
+
+ if ( ! file_exists($this->output_file))
+ return "";
+
+ $this->output = file_get_contents($this->output_file);
+ $this->output_file = NULL;
+ $this->exit_code = $exit_code;
+ $this->pid = NULL;
+
+ return $this->output;
+ }
+
+ public function execBg(): bool {
+ if ($this->cmd)
+ throw new \Exception("Command already executed!");
+
+ $output_file = $this->getTmpFileName();
+
+ $this->cmd = $this->startSessionCmd();
+ $this->cmd .= " >$output_file 2>&1 & echo $!";
+
+ $pid = exec($this->cmd, $output, $exit_code);
+ $this->exit_code = $exit_code;
+
+ if ($this->exit_code || !is_numeric($pid))
+ return false;
+
+ $this->pid = (int)$pid;
+ $this->output_file = $output_file;
+
+ return true;
+ }
+
+ public function execFg() {
+ if ($this->cmd)
+ throw new \Exception("Command already executed!");
+
+ $this->cmd = $this->startSessionCmd() . ' 2>&1';
+
+ exec($this->cmd, $output, $exit_code);
+ $this->exit_code = $exit_code;
+ $this->output = implode("\n", array_filter($output));
+
+ return $this->output;
+ }
+
+ private function regenerateIdCmd($locking, $destroy, $proxy): string {
+ $this->validateArgs(['handler', 'id', 'save-path']);
+
+ $args = [
+ 'handler' => $this->args['handler'],
+ 'save-path' => $this->args['save-path'],
+ 'id' => $this->args['id'],
+ 'locking-enabled' => !!$locking,
+ 'destroy' => !!$destroy,
+ 'proxy' => !!$proxy,
+ ];
+
+ return $this->buildPhpCmd(self::regenerate_id_script, $args);
+ }
+
+ public function regenerateId($locking = false, $destroy = false, $proxy = false) {
+ if ( ! $this->cmd)
+ throw new \Exception("Cannot regenerate id before starting session!");
+
+ $cmd = $this->regenerateIdCmd($locking, $destroy, $proxy);
+
+ exec($cmd, $output, $exit_code);
+
+ if ($exit_code != 0)
+ return false;
+
+ return $output[0];
+ }
+
+ private function getDataCmd(?int $lifetime): string {
+ $this->validateArgs(['handler', 'save-path', 'id']);
+
+ $args = [
+ 'handler' => $this->args['handler'],
+ 'save-path' => $this->args['save-path'],
+ 'id' => $this->args['id'],
+ 'lifetime' => is_int($lifetime) ? $lifetime : $this->args['lifetime'],
+ ];
+
+ return $this->buildPhpCmd(self::get_data_script, $args);
+ }
+
+ public function getData(?int $lifetime = NULL): string {
+ $cmd = $this->getDataCmd($lifetime);
+
+ exec($cmd, $output, $exit_code);
+ if ($exit_code != 0) {
+ return implode("\n", $output);
+ }
+
+ return $output[0];
+ }
+}
diff --git a/php-pecl-redis6.spec b/php-pecl-redis6.spec
index 04d0456..2f17c9c 100644
--- a/php-pecl-redis6.spec
+++ b/php-pecl-redis6.spec
@@ -30,24 +30,24 @@
# after 20-json, 40-igbinary and 40-msgpack
%global ini_name 50-%{pecl_name}.ini
-%global upstream_version 6.0.2
-#global upstream_prever RC2
+%global upstream_version 6.1.0
+%global upstream_prever RC1
%global sources %{pecl_name}-%{upstream_version}%{?upstream_prever}
%global _configure ../%{sources}/configure
Summary: Extension for communicating with the Redis key-value store
Name: %{?scl_prefix}php-pecl-redis6
Version: %{upstream_version}%{?upstream_prever:~%{upstream_prever}}
-Release: 2%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}}
+Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}}
License: PHP-3.01
URL: https://pecl.php.net/package/redis
Source0: https://pecl.php.net/get/%{sources}.tgz
-
-Patch0: %{pecl_name}-upstream.patch
+Source1: https://raw.githubusercontent.com/phpredis/phpredis/%{upstream_version}%{?upstream_prever}/tests/SessionHelpers.php
BuildRequires: make
BuildRequires: %{?dtsprefix}gcc
-BuildRequires: %{?scl_prefix}php-devel >= 7.2
+# see https://github.com/phpredis/phpredis/issues/2531#issuecomment-2268309251
+BuildRequires: %{?scl_prefix}php-devel >= 7.4
BuildRequires: %{?scl_prefix}php-pear
BuildRequires: %{?scl_prefix}php-json
%if %{with igbinary}
@@ -127,7 +127,7 @@ sed -e 's/role="test"/role="src"/' \
-i package.xml
cd %{sources}
-%patch -P0 -p1
+cp %{SOURCE1} tests/
# Use system library
rm -r liblzf
@@ -193,6 +193,8 @@ extension = %{pecl_name}.so
;redis.session.lock_retries = 100
;redis.session.lock_wait_time = 20000
;redis.session.early_refresh = 0
+;redis.session.compression = none
+;redis.session.compression_level = 3
EOF
@@ -220,15 +222,16 @@ peclconf() {
cd %{sources}
%{__phpize}
+sed -e 's/INSTALL_ROOT/DESTDIR/' -i build/Makefile.global
cd ../NTS
peclconf %{__phpconfig}
-make %{?_smp_mflags}
+%make_build
%if %{with_zts}
cd ../ZTS
peclconf %{__ztsphpconfig}
-make %{?_smp_mflags}
+%make_build
%endif
@@ -236,12 +239,12 @@ make %{?_smp_mflags}
%{?dtsenable}
# Install the NTS stuff
-make -C NTS install INSTALL_ROOT=%{buildroot}
+%make_install -C NTS
install -D -m 644 %{ini_name} %{buildroot}%{php_inidir}/%{ini_name}
%if %{with_zts}
# Install the ZTS stuff
-make -C ZTS install INSTALL_ROOT=%{buildroot}
+%make_install -C ZTS
install -D -m 644 %{ini_name} %{buildroot}%{php_ztsinidir}/%{ini_name}
%endif
@@ -338,6 +341,11 @@ exit $ret
%changelog
+* Mon Aug 5 2024 Remi Collet <remi@remirepo.net> - 6.1.0~RC1-1
+- update to 6.1.0RC1
+- open https://github.com/phpredis/phpredis/pull/2532 missing file
+- drop support for PHP < 7.4
+
* Thu Jul 11 2024 Remi Collet <remi@remirepo.net> - 6.0.2-2
- add upstream patch for PHP 8.4
- allow to build with valkey