8000 [FrameworkBundle] Fix activation strategy of traceable decorators · symfony/symfony@307d743 · GitHub
[go: up one dir, main page]

Skip to content

Commit 307d743

Browse files
[FrameworkBundle] Fix activation strategy of traceable decorators
1 parent 94f4d7a commit 307d743

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle;
1313

14+
use Symfony\Bundle\FrameworkBundle\Console\Application;
1415
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddDebugLogProcessorPass;
1516
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AssetsContextPass;
1617
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass;
@@ -202,6 +203,14 @@ public function build(ContainerBuilder $container): void
202203
}
203204
}
204205

206+
/**
207+
* @internal
208+
*/
209+
public static function considerProfilerEnabled(): bool
210+
{
211+
return !($GLOBALS['app'] ?? null) instanceof Application || empty($_GET) && \in_array('--profile', $_SERVER['argv'] ?? [], true);
212+
}
213+
205214
private function addCompilerPassIfExists(ContainerBuilder $container, string $class, string $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0): void
206215
{
207216
$container->addResource(new ClassExistenceResource($class));

src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
1313

1414
use Symfony\Bundle\FrameworkBundle\EventListener\ConsoleProfilerListener;
15+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
1516
use Symfony\Component\HttpKernel\Debug\VirtualRequestStack;
1617
use Symfony\Component\HttpKernel\EventListener\ProfilerListener;
1718
use Symfony\Component\HttpKernel\Profiler\FileProfilerStorage;
@@ -61,7 +62,7 @@
6162
->set('profiler.state_checker', ProfilerStateChecker::class)
6263
->args([
6364
service_locator(['profiler' => service('profiler')->ignoreOnUninitialized()]),
64-
param('kernel.runtime_mode.web'),
65+
inline_service('bool')->factory([FrameworkBundle::class, 'considerProfilerEnabled']),
6566
])
6667

6768
->set('profiler.is_disabled_state_checker', 'Closure')

0 commit comments

Comments
 (0)
0