Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit968e736

Browse files
bug#29794 Always pass $key to NullAdapter->createCacheItem (TysonAndre)
This PR was merged into the 4.2 branch.Discussion----------Always pass $key to NullAdapter->createCacheItem| Q | A| ------------- | ---| Branch? | 4.2| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes (build failure seems unrelated)| Fixed tickets || License | MIT| Doc PR |Previously, if this were called, it would throw an ArgumentCountError.I'm assuming existing code always checks hasItem, so this bug hasn't impacted many people.This was noticed via static analysis.The get() method was added to NullAdapter in symfony 4.2Commits-------1976d29 Always pass $key to NullAdapter->createCacheItem
2 parentsf7b9bb2 +1976d29 commit968e736

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

‎src/Symfony/Component/Cache/Adapter/NullAdapter.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function ($key) {
4242
*/
4343
publicfunctionget(string$key,callable$callback,float$beta =null,array &$metadata =null)
4444
{
45-
return$callback(($this->createCacheItem)());
45+
return$callback(($this->createCacheItem)($key));
4646
}
4747

4848
/**

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ public function testGetItem()
3434
$this->assertNull($item->get(),"Item's value must be null when isHit is false.");
3535
}
3636

37+
publicfunctiontestGet()
38+
{
39+
$adapter =$this->createCachePool();
40+
41+
$fetched = [];
42+
$item =$adapter->get('myKey',function ($item)use (&$fetched) {$fetched[] =$item; });
43+
$this->assertCount(1,$fetched);
44+
$item =$fetched[0];
45+
$this->assertFalse($item->isHit());
46+
$this->assertNull($item->get(),"Item's value must be null when isHit is false.");
47+
$this->assertSame('myKey',$item->getKey());
48+
}
49+
3750
publicfunctiontestHasItem()
3851
{
3952
$this->assertFalse($this->createCachePool()->hasItem('key'));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp