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 6d688f6

Browse filesBrowse files
bug #44799 [Cache] fix compat with apcu < 5.1.10 (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [Cache] fix compat with apcu < 5.1.10 | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #43565 | License | MIT | Doc PR | - (Not needed on 6.0) Commits ------- 2d8eeab [Cache] fix compat with apcu < 5.1.10
2 parents 4d95be0 + 2d8eeab commit 6d688f6
Copy full SHA for 6d688f6

File tree

Expand file treeCollapse file tree

2 files changed

+17
-1
lines changed
Filter options
Expand file treeCollapse file tree

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), $ok) ?: [] 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.