10000 [FrameworkBundle] Respect debug mode when warm up annotations by Strate · Pull Request #26513 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] Respect debug mode when warm up annotations #26513

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

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[FrameworkBundle] Respect debug mode when warm up annotations
  • Loading branch information
Strate committed Mar 13, 2018
commit 3979519f3f224fae2439c0b246360782a7b39c92
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@ class AnnotationsCacheWarmer extends AbstractPhpFileCacheWarmer
{
private $annotationReader;
private $excludeRegexp;
private $debug;

/**
* @param Reader $annotationReader
* @param string $phpArrayFile The PHP file where annotations are cached
* @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered annotations are cached
* @param bool $debug Run in debug mode
*/
public function __construct(Reader $annotationReader, $phpArrayFile, CacheItemPoolInterface $fallbackPool, $excludeRegexp = null)
public function __construct(Reader $annotationReader, $phpArrayFile, CacheItemPoolInterface $fallbackPool, $excludeRegexp = null, $debug)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've added a non-optional argument, which should have broken tests. If there are none, can you add one to prevent future regressions? As this argument is non-optional, it would also be a BC break. Can you make this argument optional with a default value to mimic the previous behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All done.
Added test for cache warmer for both cases - debug and no debug
Made argument optional

{
parent::__construct($phpArrayFile, $fallbackPool);
$this->annotationReader = $annotationReader;
$this->excludeRegexp = $excludeRegexp;
$this->debug = $debug;
}

/**
Expand All @@ -53,7 +56,7 @@ protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter)
}

$annotatedClasses = include $annotatedClassPatterns;
$reader = new CachedReader($this->annotationReader, new DoctrineProvider($arrayAdapter));
$reader = new CachedReader($this->annotationReader, new DoctrineProvider($arrayAdapter), $this->debug);

foreach ($annotatedClasses as $class) {
if (null !== $this->excludeRegexp && preg_match($this->excludeRegexp, $class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<argument>%kernel.cache_dir%/annotations.php</argument>
<argument type="service" id="cache.annotations" />
<argument>#^Symfony\\(?:Component\\HttpKernel\\|Bundle\\FrameworkBundle\\Controller\\(?!AbstractController$|Controller$))#</argument>
<argument>%kernel.debug%</argument>
</service>

<service id="annotations.cache" class="Symfony\Component\Cache\DoctrineProvider">
Expand Down
0