-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] fix ValidatorCacheWarmer: use serializing ArrayAdapter #23558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
9b84d72
8753b06
71b41f7
6bd0398
44ffbf5
8ab2ad6
73abab8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,9 +57,7 @@ public function warmUp($cacheDir) | |
|
||
spl_autoload_register(array($phpArrayAdapter, 'throwOnRequiredClass')); | ||
try { | ||
if (false === $this->doWarmUp($cacheDir, $phpArrayAdapter, $arrayAdapter)) { | ||
return; | ||
} | ||
$this->doWarmUp($cacheDir, $arrayAdapter); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you still need the if (!doWarmUp) then return; check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But then this is not done anymore? https://github.com/symfony/symfony/pull/23558/files#diff-ec41b7a9f7c5b4c51f70679eb93504b8L61 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it will if we make dowarmup return true or false to allow/prevent the warmup There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah now I see what you meant 😄 👍 Done. |
||
} finally { | ||
spl_autoload_unregister(array($phpArrayAdapter, 'throwOnRequiredClass')); | ||
} | ||
|
@@ -83,11 +81,8 @@ protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array | |
} | ||
|
||
/** | ||
* @param string $cacheDir | ||
* @param PhpArrayAdapter $phpArrayAdapter | ||
* @param ArrayAdapter $arrayAdapter | ||
* | ||
* @return bool|void false if there is nothing to warm-up | ||
* @param string $cacheDir | ||
* @param ArrayAdapter $arrayAdapter | ||
*/ | ||
abstract protected function doWarmUp($cacheDir, PhpArrayAdapter $phpArrayAdapter, ArrayAdapter $arrayAdapter); | ||
abstract protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ | |
use Doctrine\Common\Annotations\Reader; | ||
use Psr\Cache\CacheItemPoolInterface; | ||
use Symfony\Component\Cache\Adapter\ArrayAdapter; | ||
use Symfony\Component\Cache\Adapter\PhpArrayAdapter; | ||
use Symfony\Component\Cache\DoctrineProvider; | ||
|
||
/** | ||
|
@@ -43,14 +42,12 @@ public function __construct(Reader $annotationReader, $phpArrayFile, CacheItemPo | |
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function doWarmUp($cacheDir, PhpArrayAdapter $phpArrayAdapter, ArrayAdapter $arrayAdapter) | ||
protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter) | ||
{ | ||
$annotatedClassPatterns = $cacheDir.'/annotations.map'; | ||
|
||
if (!is_file($annotatedClassPatterns)) { | ||
$phpArrayAdapter->warmUp(array()); | ||
|
||
return false; | ||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return true |
||
} | ||
|
||
$annotatedClasses = include $annotatedClassPatterns; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ | |
use Doctrine\Common\Annotations\AnnotationException; | ||
use Psr\Cache\CacheItemPoolInterface; | ||
use Symfony\Component\Cache\Adapter\ArrayAdapter; | ||
use Symfony\Component\Cache\Adapter\PhpArrayAdapter; | ||
use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory; | ||
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory; | ||
use Symfony\Component\Serializer\Mapping\Loader\LoaderChain; | ||
|
@@ -45,10 +44,10 @@ public function __construct(array $loaders, $phpArrayFile, CacheItemPoolInterfac | |
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function doWarmUp($cacheDir, PhpArrayAdapter $phpArrayAdapter, ArrayAdapter $arrayAdapter) | ||
protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter) | ||
{ | ||
if (!class_exists(CacheClassMetadataFactory::class) || !method_exists(XmlFileLoader::class, 'getMappedClasses') || !method_exists(YamlFileLoader::class, 'getMappedClasses')) { | ||
return false; | ||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return false |
||
} | ||
|
||
$metadataFactory = new CacheClassMetadataFactory(new ClassMetadataFactory(new LoaderChain($this->loaders)), $arrayAdapter); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,10 +46,10 @@ public function __construct(ValidatorBuilderInterface $validatorBuilder, $phpArr | |
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function doWarmUp($cacheDir, PhpArrayAdapter $phpArrayAdapter, ArrayAdapter $arrayAdapter) | ||
protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter) | ||
{ | ||
if (!method_exists($this->validatorBuilder, 'getLoaders')) { | ||
return false; | ||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return false |
||
} | ||
|
||
$loaders = $this->validatorBuilder->getLoaders(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we don't need the instance yet, let's use PhpArrayAdapter::class here instead, and create the object later, (or never when dowarmup returns false)