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

Commitff47aa1

Browse files
committed
review changes
1 parent8753b06 commitff47aa1

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

‎src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
useSymfony\Component\Cache\Adapter\ProxyAdapter;
1919
useSymfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
2020

21+
/**
22+
* @internal This class is meant for internal use only.
23+
*/
2124
abstractclass AbstractPhpFileCacheWarmerimplements CacheWarmerInterface
2225
{
2326
protected$phpArrayFile;
@@ -36,6 +39,14 @@ public function __construct($phpArrayFile, CacheItemPoolInterface $fallbackPool)
3639
$this->fallbackPool =$fallbackPool;
3740
}
3841

42+
/**
43+
* {@inheritdoc}
44+
*/
45+
publicfunctionisOptional()
46+
{
47+
returntrue;
48+
}
49+
3950
/**
4051
* {@inheritdoc}
4152
*/
@@ -56,8 +67,8 @@ public function warmUp($cacheDir)
5667
// the ArrayAdapter stores the values serialized
5768
// to avoid mutation of the data after it was written to the cache
5869
// so here we un-serialize the values first
59-
$values =array_map(function ($val) {returnunserialize($val); },array_filter($arrayAdapter->getValues()));
60-
$phpArrayAdapter->warmUp($values);
70+
$values =array_map(function ($val) {returnnull !==$val ?unserialize($val) :null; },$arrayAdapter->getValues());
71+
$this->warmUpPhpArrayAdapter($phpArrayAdapter,$values);
6172

6273
foreach ($valuesas$k =>$v) {
6374
$item =$this->fallbackPool->getItem($k);
@@ -66,6 +77,11 @@ public function warmUp($cacheDir)
6677
$this->fallbackPool->commit();
6778
}
6879

80+
protectedfunctionwarmUpPhpArrayAdapter(PhpArrayAdapter$phpArrayAdapter,array$values)
81+
{
82+
$phpArrayAdapter->warmUp($values);
83+
}
84+
6985
/**
7086
* @param string $cacheDir
7187
* @param PhpArrayAdapter $phpArrayAdapter

‎src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ public function __construct(Reader $annotationReader, $phpArrayFile, CacheItemPo
4040
$this->annotationReader =$annotationReader;
4141
}
4242

43-
/**
44-
* {@inheritdoc}
45-
*/
46-
publicfunctionisOptional()
47-
{
48-
returntrue;
49-
}
50-
5143
/**
5244
* {@inheritdoc}
5345
*/

‎src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,6 @@ public function __construct(array $loaders, $phpArrayFile, CacheItemPoolInterfac
4242
$this->loaders =$loaders;
4343
}
4444

45-
/**
46-
* {@inheritdoc}
47-
*/
48-
publicfunctionisOptional()
49-
{
50-
returntrue;
51-
}
52-
5345
/**
5446
* {@inheritdoc}
5547
*/

‎src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ public function __construct(ValidatorBuilderInterface $validatorBuilder, $phpArr
4343
$this->validatorBuilder =$validatorBuilder;
4444
}
4545

46-
/**
47-
* {@inheritdoc}
48-
*/
49-
publicfunctionisOptional()
50-
{
51-
returntrue;
52-
}
53-
5446
/**
5547
* {@inheritdoc}
5648
*/
@@ -78,6 +70,12 @@ protected function doWarmUp($cacheDir, PhpArrayAdapter $phpArrayAdapter, ArrayAd
7870
}
7971
}
8072

73+
protectedfunctionwarmUpPhpArrayAdapter(PhpArrayAdapter$phpArrayAdapter,array$values)
74+
{
75+
// make sure we don't cache null values
76+
parent::warmUpPhpArrayAdapter($phpArrayAdapter,array_filter($values));
77+
}
78+
8179
/**
8280
* @param LoaderInterface[] $loaders
8381
*

‎src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
useSymfony\Bundle\FrameworkBundle\CacheWarmer\ValidatorCacheWarmer;
1515
useSymfony\Bundle\FrameworkBundle\Tests\TestCase;
1616
useSymfony\Component\Cache\Adapter\ArrayAdapter;
17+
useSymfony\Component\Validator\Mapping\Loader\YamlFileLoader;
1718
useSymfony\Component\Validator\ValidatorBuilder;
1819

1920
class ValidatorCacheWarmerTestextends TestCase
@@ -79,8 +80,9 @@ public function testWarmUpWithAnnotations()
7980
$values =$fallbackPool->getValues();
8081

8182
$this->assertInternalType('array',$values);
82-
$this->assertCount(1,$values);
83+
$this->assertCount(2,$values);
8384
$this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Category',$values);
85+
$this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.SubCategory',$values);
8486
}
8587

8688
publicfunctiontestWarmUpWithoutLoader()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp