8000 Merge branch '4.4' into 5.3 · symfony/cache@135d759 · GitHub
[go: up one dir, main page]

Skip to content

Commit 135d759

Browse files
committed
Merge branch '4.4' into 5.3
* 4.4: [Cache] fix compat with apcu < 5.1.10 Run `open_basedir` tests in separate processes
2 parents e866d48 + c9467ba commit 135d759

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Adapter/ApcuAdapter.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ protected function doFetch(array $ids)
6060
$unserializeCallbackHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback');
6161
try {
6262
$values = [];
63-
foreach (apcu_fetch($ids, $ok) ?: [] as $k => $v) {
63+
$ids = array_flip($ids);
64+
foreach (apcu_fetch(array_keys($ids), $ok) ?: [] as $k => $v) {
65+
if (!isset($ids[$k])) {
66+
// work around https://github.com/krakjoe/apcu/issues/247
67+
$k = key($ids);
68+
}
69+
unset($ids[$k]);
70+
6471
if (null !== $v || $ok) {
6572
$values[$k] = null !== $this->marshaller ? $this->marshaller->unmarshall($v) : $v;
6673
}

Tests/Adapter/AdapterTestCase.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,15 @@ public function testWeirdDataMatchingMetadataWrappedValues()
306306

307307
$this->assertTrue($cache->hasItem('foobar'));
308308
}
309+
310+
public function testNullByteInKey()
311+
{
312+
$cache = $this->createCachePool(0, __FUNCTION__);
313+
314+
$cache->save($cache->getItem("a\0b")->set(123));
315+
316+
$this->assertSame(123, $cache->getItem("a\0b")->get());
317+
}
309318
}
310319

311320
class NotUnserializable

0 commit comments

Comments
 (0)
0