Skip to content

Commit a314b65

Browse files
bug #52870 [SecurityBundle] Fix redeclaration of InternalSecurity class when opcache preload is active (kaznovac)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [SecurityBundle] Fix redeclaration of `InternalSecurity` class when opcache preload is active | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | | License | MIT When opcache.preload is active the `InternalSecurity` gets aliased twice. I have security voter in project that injects `Symfony\Bundle\SecurityBundle\Security` and the `opcache.preload` php config is set. Stack trace: ``` ErrorException: Warning: Cannot declare class Symfony\Bundle\SecurityBundle\InternalSecurity, because the name is already in use at vendor/symfony/security-bundle/Security.php:34 at include_once('/var/www/vendor/symfony/security-bundle/Security.php') (var/cache/dev/ContainerSgUiPaP/App_KernelDevDebugContainer.php:6191) at ContainerSgUiPaP\App_KernelDevDebugContainer::getSecurity_HelperService(object(App_KernelDevDebugContainer)) (var/cache/dev/ContainerSgUiPaP/App_KernelDevDebugContainer.php:3537) at ContainerSgUiPaP\App_KernelDevDebugContainer::getImageVoter2Service(object(App_KernelDevDebugContainer)) (var/cache/dev/ContainerSgUiPaP/App_KernelDevDebugContainer.php:2198) at ContainerSgUiPaP\App_KernelDevDebugContainer::getImageVoterService(object(App_KernelDevDebugContainer)) (var/cache/dev/ContainerSgUiPaP/App_KernelDevDebugContainer.php:4671) at ContainerSgUiPaP\App_KernelDevDebugContainer::ContainerSgUiPaP\{closure}() (vendor/symfony/security-bundle/DataCollector/SecurityDataCollector.php:135) at Symfony\Bundle\SecurityBundle\DataCollector\SecurityDataCollector->collect(object(Request), object(Response), null) (vendor/symfony/http-kernel/Profiler/Profiler.php:169) at Symfony\Component\HttpKernel\Profiler\Profiler->collect(object(Request), object(Response), null) (vendor/symfony/http-kernel/EventListener/ProfilerListener.php:108) at Symfony\Component\HttpKernel\EventListener\ProfilerListener->onKernelResponse(object(ResponseEvent), 'kernel.response', object(TraceableEventDispatcher)) (vendor/symfony/event-dispatcher/Debug/WrappedListener.php:116) at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(ResponseEvent), 'kernel.response', object(TraceableEventDispatcher)) (vendor/symfony/event-dispatcher/EventDispatcher.php:220) at Symfony\Component\EventDispatcher\EventDispatcher->callListeners(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.response', object(ResponseEvent)) (vendor/symfony/event-dispatcher/EventDispatcher.php:56) at Symfony\Component\EventDispatcher\EventDispatcher->dispatch(object(ResponseEvent), 'kernel.response') (vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:139) at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch(object(ResponseEvent), 'kernel.response') (vendor/symfony/http-kernel/HttpKernel.php:214) at Symfony\Component\HttpKernel\HttpKernel->filterResponse(object(Response), object(Request), 1) (vendor/symfony/http-kernel/HttpKernel.php:202) at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1) (vendor/symfony/http-kernel/HttpKernel.php:76) at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true) (vendor/symfony/http-kernel/Kernel.php:197) at Symfony\Component\HttpKernel\Kernel->handle(object(Request)) (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35) at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run() (vendor/autoload_runtime.php:29) at require_once('/var/www/vendor/autoload_runtime.php') (public/index.php:5) ``` Commits ------- 4651fef [SecurityBundle] Fix redeclaration of `InternalSecurity` class when opcache preload is active
2 parents abf4125 + 4651fef commit a314b65

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Symfony/Bundle/SecurityBundle/Security.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
use Symfony\Component\Security\Http\SecurityRequestAttributes;
3131
use Symfony\Contracts\Service\ServiceProviderInterface;
3232

33+
if (class_exists(InternalSecurity::class, false)) {
34+
return;
35+
}
3336
if (class_exists(LegacySecurity::class)) {
3437
class_alias(LegacySecurity::class, InternalSecurity::class);
3538
} else {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy