summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--PHPINFO2
-rw-r--r--REFLECTION2
-rw-r--r--SessionHelpers.php353
-rw-r--r--php-pecl-redis6.spec11
-rw-r--r--redis-upstream.patch116
5 files changed, 7 insertions, 477 deletions
diff --git a/PHPINFO b/PHPINFO
index 35333b6..dc83670 100644
--- a/PHPINFO
+++ b/PHPINFO
@@ -2,7 +2,7 @@
redis
Redis Support => enabled
-Redis Version => 6.1.0RC1
+Redis Version => 6.1.0RC2
Redis Sentinel Version => 1.0
Available serializers => php, json, igbinary, msgpack
Available compression => lzf, zstd, lz4
diff --git a/REFLECTION b/REFLECTION
index 74d6e30..4f320ec 100644
--- a/REFLECTION
+++ b/REFLECTION
@@ -1,4 +1,4 @@
-Extension [ <persistent> extension #107 redis version 6.1.0RC1 ] {
+Extension [ <persistent> extension #113 redis version 6.1.0RC2 ] {
- Dependencies {
Dependency [ igbinary (Required) ]
diff --git a/SessionHelpers.php b/SessionHelpers.php
deleted file mode 100644
index 90ae73b..0000000
--- a/SessionHelpers.php
+++ /dev/null
@@ -1,353 +0,0 @@
-<?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 2f17c9c..142f068 100644
--- a/php-pecl-redis6.spec
+++ b/php-pecl-redis6.spec
@@ -31,22 +31,20 @@
%global ini_name 50-%{pecl_name}.ini
%global upstream_version 6.1.0
-%global upstream_prever RC1
+%global upstream_prever RC2
%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: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}}
+Release: 0%{?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
-Source1: https://raw.githubusercontent.com/phpredis/phpredis/%{upstream_version}%{?upstream_prever}/tests/SessionHelpers.php
BuildRequires: make
BuildRequires: %{?dtsprefix}gcc
-# 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
@@ -127,8 +125,6 @@ sed -e 's/role="test"/role="src"/' \
-i package.xml
cd %{sources}
-cp %{SOURCE1} tests/
-
# Use system library
rm -r liblzf
@@ -341,6 +337,9 @@ exit $ret
%changelog
+* Mon Sep 23 2024 Remi Collet <remi@remirepo.net> - 6.1.0~RC2-0
+- test build for upcoming 6.1.0RC2
+
* 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
diff --git a/redis-upstream.patch b/redis-upstream.patch
deleted file mode 100644
index 03bd34f..0000000
--- a/redis-upstream.patch
+++ /dev/null
@@ -1,116 +0,0 @@
-From a51215ce2b22bcd1f506780c35b6833471e0b8cb Mon Sep 17 00:00:00 2001
-From: michael-grunder <michael.grunder@gmail.com>
-Date: Mon, 18 Mar 2024 14:42:35 -0700
-Subject: [PATCH] Update random includes.
-
-PHP 8.4 has some breaking changes with respect to where PHP's random methods and
-helpers are. This commit fixes those issues while staying backward compatible.
-
-Fixes #2463
----
- backoff.c | 12 ++++++------
- library.c | 7 ++++++-
- redis.c | 6 +++++-
- 3 files changed, 17 insertions(+), 8 deletions(-)
-
-diff --git a/backoff.c b/backoff.c
-index d0961fcfaf..1be04a8fe8 100644
---- a/backoff.c
-+++ b/backoff.c
-@@ -1,14 +1,14 @@
- #include "common.h"
-
-+#if PHP_VERSION_ID < 80400
- #include <ext/standard/php_rand.h>
--
--#if PHP_VERSION_ID >= 70100
--#include <ext/standard/php_mt_rand.h>
- #else
-+#include <ext/random/php_random.h>
-+#endif
-+
-+#if PHP_VERSION_ID < 70100
- static zend_long php_mt_rand_range(zend_long min, zend_long max) {
-- zend_long number = php_rand();
-- RAND_RANGE(number, min, max, PHP_RAND_MAX);
-- return number;
-+ return min + php_rand() % (max - min + 1)
- }
- #endif
-
-diff --git a/library.c b/library.c
-index 3d65c8529d..f81556a9ed 100644
---- a/library.c
-+++ b/library.c
-@@ -56,9 +56,14 @@
- #include <ext/json/php_json.h>
- #endif
-
--#include <ext/standard/php_rand.h>
- #include <ext/hash/php_hash.h>
-
-+#if PHP_VERSION_ID < 80400
-+#include <ext/standard/php_rand.h>
-+#else
-+#include <ext/random/php_random.h>
-+#endif
-+
- #define UNSERIALIZE_NONE 0
- #define UNSERIALIZE_KEYS 1
- #define UNSERIALIZE_VALS 2
-diff --git a/redis.c b/redis.c
-index ec6f65d2ed..2330bf7edf 100644
---- a/redis.c
-+++ b/redis.c
-@@ -27,12 +27,16 @@
- #include "redis_cluster.h"
- #include "redis_commands.h"
- #include "redis_sentinel.h"
--#include <standard/php_random.h>
- #include <ext/spl/spl_exceptions.h>
- #include <zend_exceptions.h>
- #include <ext/standard/info.h>
- #include <ext/hash/php_hash.h>
-
-+#if PHP_VERSION_ID < 80400
-+#include <ext/standard/php_random.h>
-+#else
-+#include <ext/random/php_random.h>
-+#endif
-
- #ifdef PHP_SESSION
- #include <ext/session/php_session.h>
-From c139de3abac1dd33b97ef0de5af41b6e3a78f7ab Mon Sep 17 00:00:00 2001
-From: michael-grunder <michael.grunder@gmail.com>
-Date: Sat, 1 Jun 2024 13:09:30 -0700
-Subject: [PATCH] We don't need to use a ranom value for our ECHO liveness
- challenge.
-
-A microsecond resolution timestamp combined with a monotonically
-incremented counter should be sufficient.
-
-This also fixes PHP 8.4 compilation as PHP 8.4 doesn't seem to have
-`php_rand()`.
----
- library.c | 4 +++-
- 1 file changed, 3 insertions(+), 1 deletion(-)
-
-diff --git a/library.c b/library.c
-index ce0cbda26..42a132c4c 100644
---- a/library.c
-+++ b/library.c
-@@ -2886,11 +2886,13 @@ redis_sock_create(char *host, int host_len, int port,
- }
-
- static int redis_uniqid(char *buf, size_t buflen) {
-+ static unsigned long counter = 0;
- struct timeval tv;
-+
- gettimeofday(&tv, NULL);
-
- return snprintf(buf, buflen, "phpredis:%08lx%05lx:%08lx",
-- (long)tv.tv_sec, (long)tv.tv_usec, (long)php_rand());
-+ (long)tv.tv_sec, (long)tv.tv_usec, counter++);
- }
-
- static int redis_stream_liveness_check(php_stream *stream) {