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

Commit8c43fac

Browse files
committed
bug#40780 [Cache] Apply NullAdapter as Null Object (roukmoute)
This PR was squashed before being merged into the 4.4 branch.Discussion----------[Cache] Apply NullAdapter as Null Object| Q | A| ------------- | ---| Branch? | 4.4| Bug fix? | yes| New feature? | no <!-- please update src/**/CHANGELOG.md files -->| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tickets |Fix#40753| License | MIT<!--| Doc PR | symfony/symfony-docs#... <!-- required for new features -->There is a problem with the NullAdapter if I have to add an expression to work:```php$adapter = new NullAdapter();$item = new CacheItem();$item->set('FooBar');if (!$adapter->save($item) && !($adapter instanceof NullAdapter)) { throw new Exception('Uoh oh');}```So the goal here is to modify the methods that are causing a problem to behave as a Null Object.Commits-------f6818eb [Cache] Apply NullAdapter as Null Object
2 parentse05b4ef +f6818eb commit8c43fac

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function deleteItems(array $keys)
114114
*/
115115
publicfunctionsave(CacheItemInterface$item)
116116
{
117-
returnfalse;
117+
returntrue;
118118
}
119119

120120
/**
@@ -124,7 +124,7 @@ public function save(CacheItemInterface $item)
124124
*/
125125
publicfunctionsaveDeferred(CacheItemInterface$item)
126126
{
127-
returnfalse;
127+
returntrue;
128128
}
129129

130130
/**
@@ -134,7 +134,7 @@ public function saveDeferred(CacheItemInterface $item)
134134
*/
135135
publicfunctioncommit()
136136
{
137-
returnfalse;
137+
returntrue;
138138
}
139139

140140
/**

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function testSave()
113113
$this->assertFalse($item->isHit());
114114
$this->assertNull($item->get(),"Item's value must be null when isHit is false.");
115115

116-
$this->assertFalse($adapter->save($item));
116+
$this->assertTrue($adapter->save($item));
117117
}
118118

119119
publicfunctiontestDeferredSave()
@@ -124,7 +124,7 @@ public function testDeferredSave()
124124
$this->assertFalse($item->isHit());
125125
$this->assertNull($item->get(),"Item's value must be null when isHit is false.");
126126

127-
$this->assertFalse($adapter->saveDeferred($item));
127+
$this->assertTrue($adapter->saveDeferred($item));
128128
}
129129

130130
publicfunctiontestCommit()
@@ -135,7 +135,7 @@ public function testCommit()
135135
$this->assertFalse($item->isHit());
136136
$this->assertNull($item->get(),"Item's value must be null when isHit is false.");
137137

138-
$this->assertFalse($adapter->saveDeferred($item));
139-
$this->assertFalse($this->createCachePool()->commit());
138+
$this->assertTrue($adapter->saveDeferred($item));
139+
$this->assertTrue($this->createCachePool()->commit());
140140
}
141141
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp