bug #25425 When available use AnnotationRegistry::registerUniqueLoader (jrjohnson)
This PR was merged into the 3.3 branch.
Discussion
----------
When available use AnnotationRegistry::registerUniqueLoader
| Q | A
| ------------- | ---
| Branch? | 3.3
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| References tickets | #24596
| License | MIT
Take advantage of AnnotationRegistry::registerUniqueLoader which will only add 'class_exists' as an autoloader if it has not already been added. This helps alleviate a performance issue when the
same loader is added many times in tests.
Commits
-------
97c3f429eb
Take advantage of AnnotationRegistry::registerUniqueLoader
This commit is contained in:
commit
258776b31d
@ -120,7 +120,11 @@ class SymfonyTestsListenerTrait
|
|||||||
$this->state = 0;
|
$this->state = 0;
|
||||||
|
|
||||||
if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
|
if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
|
||||||
AnnotationRegistry::registerLoader('class_exists');
|
if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) {
|
||||||
|
AnnotationRegistry::registerUniqueLoader('class_exists');
|
||||||
|
} else {
|
||||||
|
AnnotationRegistry::registerLoader('class_exists');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->skippedFile = getenv('SYMFONY_PHPUNIT_SKIPPED_TESTS')) {
|
if ($this->skippedFile = getenv('SYMFONY_PHPUNIT_SKIPPED_TESTS')) {
|
||||||
|
@ -28,7 +28,11 @@ if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists('PHPUnit_TextUI_Comman
|
|||||||
setlocale(LC_ALL, 'C');
|
setlocale(LC_ALL, 'C');
|
||||||
|
|
||||||
if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
|
if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
|
||||||
AnnotationRegistry::registerLoader('class_exists');
|
if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) {
|
||||||
|
AnnotationRegistry::registerUniqueLoader('class_exists');
|
||||||
|
} else {
|
||||||
|
AnnotationRegistry::registerLoader('class_exists');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) {
|
if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) {
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
|
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
|
||||||
|
|
||||||
use Doctrine\Common\Annotations\Reader;
|
use Doctrine\Common\Annotations\Reader;
|
||||||
|
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||||
use Symfony\Bridge\Monolog\Processor\DebugProcessor;
|
use Symfony\Bridge\Monolog\Processor\DebugProcessor;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
@ -1087,6 +1088,11 @@ class FrameworkExtension extends Extension
|
|||||||
|
|
||||||
$loader->load('annotations.xml');
|
$loader->load('annotations.xml');
|
||||||
|
|
||||||
|
if (!method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
|
||||||
|
$container->getDefinition('annotations.dummy_registry')
|
||||||
|
->setMethodCalls(array(array('registerLoader', array('class_exists'))));
|
||||||
|
}
|
||||||
|
|
||||||
if ('none' !== $config['cache']) {
|
if ('none' !== $config['cache']) {
|
||||||
$cacheService = $config['cache'];
|
$cacheService = $config['cache'];
|
||||||
|
|
||||||
|
@ -10,14 +10,14 @@
|
|||||||
<service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader">
|
<service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader">
|
||||||
<call method="addGlobalIgnoredName">
|
<call method="addGlobalIgnoredName">
|
||||||
<argument>required</argument>
|
<argument>required</argument>
|
||||||
<argument type="service">
|
<!-- dummy arg to register class_exists as annotation loader only when required -->
|
||||||
<!-- dummy arg to register class_exists as annotation loader only when required -->
|
<argument type="service" id="annotations.dummy_registry" />
|
||||||
<service class="Doctrine\Common\Annotations\AnnotationRegistry">
|
</call>
|
||||||
<call method="registerLoader">
|
</service>
|
||||||
<argument>class_exists</argument>
|
|
||||||
</call>
|
<service id="annotations.dummy_registry" class="Doctrine\Common\Annotations\AnnotationRegistry">
|
||||||
</service>
|
<call method="registerUniqueLoader">
|
||||||
</argument>
|
<argument>class_exists</argument>
|
||||||
</call>
|
</call>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user