8000 [Cache] Disable igbinary on PHP >= 7.4 by nicolas-grekas · Pull Request #34419 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Cache] Disable igbinary on PHP >= 7.4 #34419

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

Merged
merged 1 commit into from
Nov 17, 2019
Merged
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
[Cache] Disable igbinary on PHP >= 7.4
  • Loading branch information
nicolas-grekas committed Nov 17, 2019
commit a2c924d77220011c5f5939579677d2a82b69a43d
8 changes: 4 additions & 4 deletions src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class DefaultMarshaller implements MarshallerInterface
public function __construct(bool $useIgbinarySerialize = null)
{
if (null === $useIgbinarySerialize) {
$useIgbinarySerialize = \extension_loaded('igbinary') && \PHP_VERSION_ID !== 70400;
} elseif ($useIgbinarySerialize && (!\extension_loaded('igbinary') || \PHP_VERSION_ID === 70400)) {
throw new CacheException('The "igbinary" PHP extension is not '.(\PHP_VERSION_ID === 70400 ? 'compatible with PHP 7.4.0.' : 'loaded.'));
$useIgbinarySerialize = \extension_loaded('igbinary') && \PHP_VERSION_ID < 70400;
} elseif ($useIgbinarySerialize && (!\extension_loaded('igbinary') || \PHP_VERSION_ID >= 70400)) {
throw new CacheException('The "igbinary" PHP extension is not '.(\PHP_VERSION_ID >= 70400 ? 'compatible with PHP 7.4.' : 'loaded.'));
}
$this->useIgbinarySerialize = $useIgbinarySerialize;
}
Expand Down Expand Up @@ -66,7 +66,7 @@ public function unmarshall(string $value)
return null;
}
static $igbinaryNull;
if ($value === ($igbinaryNull ?? $igbinaryNull = \extension_loaded('igbinary') && \PHP_VERSION_ID !== 70400 ? igbinary_serialize(null) : false)) {
if ($value === ($igbinaryNull ?? $igbinaryNull = \extension_loaded('igbinary') && \PHP_VERSION_ID < 70400 ? igbinary_serialize(null) : false)) {
return null;
}
$unserializeCallbackHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testSerialize()
'b' => function () {},
];

$expected = ['a' => \extension_loaded('igbinary') && \PHP_VERSION_ID !== 70400 ? igbinary_serialize(123) : serialize(123)];
$expected = ['a' => \extension_loaded('igbinary') && \PHP_VERSION_ID < 70400 ? igbinary_serialize(123) : serialize(123)];
$this->assertSame($expected, $marshaller->marshall($values, $failed));
$this->assertSame(['b'], $failed);
}
Expand All @@ -43,8 +43,8 @@ public function testNativeUnserialize()
*/
public function testIgbinaryUnserialize()
{
if (\PHP_VERSION_ID === 70400) {
$this->markTestSkipped('igbinary is not compatible with PHP 7.4.0.');
if (\PHP_VERSION_ID >= 70400) {
$this->markTestSkipped('igbinary is not compatible with PHP 7.4.');
}

$marshaller = new DefaultMarshaller();
Expand All @@ -67,8 +67,8 @@ public function testNativeUnserializeNotFoundClass()
*/
public function testIgbinaryUnserializeNotFoundClass()
{
if (\PHP_VERSION_ID === 70400) {
$this->markTestSkipped('igbinary is not compatible with PHP 7.4.0.');
if (\PHP_VERSION_ID >= 70400) {
$this->markTestSkipped('igbinary is not compatible with PHP 7.4.');
}

$this->expectException('DomainException');
Expand All @@ -95,8 +95,8 @@ public function testNativeUnserializeInvalid()
*/
public function testIgbinaryUnserializeInvalid()
{
if (\PHP_VERSION_ID === 70400) {
$this->markTestSkipped('igbinary is not compatible with PHP 7.4.0');
if (\PHP_VERSION_ID >= 70400) {
$this->markTestSkipped('igbinary is not compatible with PHP 7.4.');
}

$this->expectException('DomainException');
Expand Down
0