Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;

use Composer\InstalledVersions;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\Common\Annotations\Reader;
use Http\Client\HttpClient;
use phpDocumentor\Reflection\DocBlockFactoryInterface;
Expand Down Expand Up @@ -1631,15 +1630,6 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde

$loader->load('annotations.php');

if (!method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
if (method_exists(AnnotationRegistry::class, 'registerLoader')) {
$container->getDefinition('annotations.dummy_registry')
->setMethodCalls([['registerLoader', ['class_exists']]]);
} else {
$container->removeDefinition('annotations.dummy_registry');
}
}

if ('none' === $config['cache']) {
$container->removeDefinition('annotations.cached_reader');

Expand Down Expand Up @@ -2687,12 +2677,18 @@ private function resolveTrustedHeaders(array $headers): int

foreach ($headers as $h) {
switch ($h) {
case 'forwarded': $trustedHeaders |= Request::HEADER_FORWARDED; break;
case 'x-forwarded-for': $trustedHeaders |= Request::HEADER_X_FORWARDED_FOR; break;
case 'x-forwarded-host': $trustedHeaders |= Request::HEADER_X_FORWARDED_HOST; break;
case 'x-forwarded-proto': $trustedHeaders |= Request::HEADER_X_FORWARDED_PROTO; break;
case 'x-forwarded-port': $trustedHeaders |= Request::HEADER_X_FORWARDED_PORT; break;
case 'x-forwarded-prefix': $trustedHeaders |= Request::HEADER_X_FORWARDED_PREFIX; break;
case 'forwarded': $trustedHeaders |= Request::HEADER_FORWARDED;
break;
case 'x-forwarded-for': $trustedHeaders |= Request::HEADER_X_FORWARDED_FOR;
break;
case 'x-forwarded-host': $trustedHeaders |= Request::HEADER_X_FORWARDED_HOST;
break;
case 'x-forwarded-proto': $trustedHeaders |= Request::HEADER_X_FORWARDED_PROTO;
break;
case 'x-forwarded-port': $trustedHeaders |= Request::HEADER_X_FORWARDED_PORT;
break;
case 'x-forwarded-prefix': $trustedHeaders |= Request::HEADER_X_FORWARDED_PREFIX;
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,30 @@
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;

return static function (ContainerConfigurator $container) {
$container->services()
->set('annotations.reader', AnnotationReader::class)
// compatibility layer to support doctrine/annotations ^1.13 and ^2.0
// registerUniqueLoader only exists in doctrine/annotations ^1.13
// (it was added in 1.6 but a conflict forbid versions lower than 1.13.1)
if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
$container->services()
->set('annotations.dummy_registry', AnnotationRegistry::class)
->call('registerUniqueLoader', ['class_exists']);

$container->services()
->set('annotations.reader', AnnotationReader::class)
->call('addGlobalIgnoredName', [
'required',
service('annotations.dummy_registry')->ignoreOnInvalid(), // dummy arg to register class_exists as annotation loader only when required
])
;
}
// with doctrine/annotations v2, there's no need for annotations.dummy_registry
else {
$container->services()
->set('annotations.reader', AnnotationReader::class)
->call('addGlobalIgnoredName', ['required']);
}

->set('annotations.dummy_registry', AnnotationRegistry::class)
->call('registerUniqueLoader', ['class_exists'])

$container->services()
->set('annotations.cached_reader', PsrCachedReader::class)
->args([
service('annotations.reader'),
Expand Down