Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9cf1260

Browse filesBrowse files
[Cache] fix compat with apcu < 5.1.10
1 parent 9d9f27a commit 9cf1260
Copy full SHA for 9cf1260

File tree

2 files changed

+17
-1
lines changed
Filter options

2 files changed

+17
-1
lines changed

‎src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,15 @@ public function testWeirdDataMatchingMetadataWrappedValues()
296296

297297
$this->assertTrue($cache->hasItem('foobar'));
298298
}
299+
300+
public function testNullByteInKey()
301+
{
302+
$cache = $this->createCachePool(0, __FUNCTION__);
303+
304+
$cache->save($cache->getItem("a\0b")->set(123));
305+
306+
$this->assertSame(123, $cache->getItem("a\0b")->get());
307+
}
299308
}
300309

301310
class NotUnserializable

‎src/Symfony/Component/Cache/Traits/ApcuTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Traits/ApcuTrait.php
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ protected function doFetch(array $ids)
5454
$unserializeCallbackHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback');
5555
try {
5656
$values = [];
57-
foreach (apcu_fetch($ids, $ok) ?: [] as $k => $v) {
57+
$ids = array_flip($ids);
58+
foreach (apcu_fetch(array_keys($ids)) ?: [] as $k => $v) {
59+
if (!isset($ids[$k])) {
60+
// work around https://github.com/krakjoe/apcu/issues/247
61+
$k = key($ids);
62+
}
63+
unset($ids[$k]);
64+
5865
if (null !== $v || $ok) {
5966
$values[$k] = $v;
6067
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.