Skip to content

Commit 479efc5

Browse files
bug #34419 [Cache] Disable igbinary on PHP >= 7.4 (nicolas-grekas)
This PR was merged into the 4.3 branch. Discussion ---------- [Cache] Disable igbinary on PHP >= 7.4 | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Until igbinary/igbinary#244 is fixed. Commits ------- a2c924d [Cache] Disable igbinary on PHP >= 7.4
2 parents d20f544 + a2c924d commit 479efc5

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class DefaultMarshaller implements MarshallerInterface
2525
public function __construct(bool $useIgbinarySerialize = null)
2626
{
2727
if (null === $useIgbinarySerialize) {
28-
$useIgbinarySerialize = \extension_loaded('igbinary') && \PHP_VERSION_ID !== 70400;
29-
} elseif ($useIgbinarySerialize && (!\extension_loaded('igbinary') || \PHP_VERSION_ID === 70400)) {
30-
throw new CacheException('The "igbinary" PHP extension is not '.(\PHP_VERSION_ID === 70400 ? 'compatible with PHP 7.4.0.' : 'loaded.'));
28+
$useIgbinarySerialize = \extension_loaded('igbinary') && \PHP_VERSION_ID < 70400;
29+
} elseif ($useIgbinarySerialize && (!\extension_loaded('igbinary') || \PHP_VERSION_ID >= 70400)) {
30+
throw new CacheException('The "igbinary" PHP extension is not '.(\PHP_VERSION_ID >= 70400 ? 'compatible with PHP 7.4.' : 'loaded.'));
3131
}
3232
$this->useIgbinarySerialize = $useIgbinarySerialize;
3333
}
@@ -66,7 +66,7 @@ public function unmarshall(string $value)
6666
return null;
6767
}
6868
static $igbinaryNull;
69-
if ($value === ($igbinaryNull ?? $igbinaryNull = \extension_loaded('igbinary') && \PHP_VERSION_ID !== 70400 ? igbinary_serialize(null) : false)) {
69+
if ($value === ($igbinaryNull ?? $igbinaryNull = \extension_loaded('igbinary') && \PHP_VERSION_ID < 70400 ? igbinary_serialize(null) : false)) {
7070
return null;
7171
}
7272
$unserializeCallbackHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback');

src/Symfony/Component/Cache/Tests/Marshaller/DefaultMarshallerTest.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testSerialize()
2424
'b' => function () {},
2525
];
2626

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

5050
$marshaller = new DefaultMarshaller();
@@ -67,8 +67,8 @@ public function testNativeUnserializeNotFoundClass()
6767
*/
6868
public function testIgbinaryUnserializeNotFoundClass()
6969
{
70-
if (\PHP_VERSION_ID === 70400) {
71-
$this->markTestSkipped('igbinary is not compatible with PHP 7.4.0.');
70+
if (\PHP_VERSION_ID >= 70400) {
71+
$this->markTestSkipped('igbinary is not compatible with PHP 7.4.');
7272
}
7373

7474
$this->expectException('DomainException');
@@ -95,8 +95,8 @@ public function testNativeUnserializeInvalid()
9595
*/
9696
public function testIgbinaryUnserializeInvalid()
9797
{
98-
if (\PHP_VERSION_ID === 70400) {
99-
$this->markTestSkipped('igbinary is not compatible with PHP 7.4.0');
98+
if (\PHP_VERSION_ID >= 70400) {
99+
$this->markTestSkipped('igbinary is not compatible with PHP 7.4.');
100100
}
101101

102102
$this->expectException('DomainException');

0 commit comments

Comments
 (0)