Skip to content

[Cache] Fix compat with ext-redis v6 #51133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ install:
- cd ext
- appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php_apcu-5.1.22-8.2-ts-vs16-x86.zip
- 7z x php_apcu-5.1.22-8.2-ts-vs16-x86.zip -y >nul
- appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php_redis-5.3.7-8.2-ts-vs16-x86.zip
- 7z x php_redis-5.3.7-8.2-ts-vs16-x86.zip -y >nul
- appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php_redis-6.0.0-dev-8.2-ts-vs16-x86.zip
- 7z x php_redis-6.0.0-dev-8.2-ts-vs16-x86.zip -y >nul
- cd ..
- copy /Y php.ini-development php.ini-min
- echo memory_limit=-1 >> php.ini-min
Expand Down
23 changes: 14 additions & 9 deletions src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class RedisProxiesTest extends TestCase
{
/**
* @requires extension redis
* @requires extension redis < 6
*
* @testWith ["Redis"]
* ["RedisCluster"]
Expand Down Expand Up @@ -85,19 +85,24 @@ public function testRelayProxy()
*/
public function testRedis6Proxy($class, $stub)
{
$this->markTestIncomplete('To be re-enabled when phpredis v6 becomes stable');

$stub = file_get_contents("https://raw.githubusercontent.com/phpredis/phpredis/develop/{$stub}.stub.php");
$stub = preg_replace('/^class /m', 'return; \0', $stub);
$stub = preg_replace('/^return; class ([a-zA-Z]++)/m', 'interface \1StubInterface', $stub, 1);
$stub = preg_replace('/^ public const .*/m', '', $stub);
eval(substr($stub, 5));
if (version_compare(phpversion('redis'), '6.0.0', '<')) {
$this->markTestIncomplete('To be re-enabled when phpredis v6 becomes stable');

$stub = file_get_contents("https://raw.githubusercontent.com/phpredis/phpredis/develop/{$stub}.stub.php");
$stub = preg_replace('/^class /m', 'return; \0', $stub);
$stub = preg_replace('/^return; class ([a-zA-Z]++)/m', 'interface \1StubInterface', $stub, 1);
$stub = preg_replace('/^ public const .*/m', '', $stub);
eval(substr($stub, 5));
$r = new \ReflectionClass($class.'StubInterface');
} else {
$r = new \ReflectionClass($class);
}

$proxy = file_get_contents(\dirname(__DIR__, 2)."/Traits/{$class}6Proxy.php");
$proxy = substr($proxy, 0, 4 + strpos($proxy, '[];'));
$methods = [];

foreach ((new \ReflectionClass($class.'StubInterface'))->getMethods() as $method) {
foreach ($r->getMethods() as $method) {
if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name)) {
continue;
}
Expand Down