8000 minor #30916 [Profiler] Update ProfilerController.php (error56) · symfony/symfony@f587944 · GitHub
[go: up one dir, main page]

Skip to content

Commit f587944

Browse files
committed
minor #30916 [Profiler] Update ProfilerController.php (error56)
This PR was squashed before being merged into the 4.3-dev branch (closes #30916). Discussion ---------- [Profiler] Update ProfilerController.php | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | n/a <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> <!-- Write a short README entry for your feature/bugfix here (replace this comment block.) This will help people understand your PR and can be used as a start of the Doc PR. Additionally: - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the master branch. --> Commits ------- 6e0785f [Profiler] Update ProfilerController.php
2 parents adba41a + 6e0785f commit f587944

File tree

1 file changed

+15
-30
lines changed

1 file changed

+15
-30
lines changed

src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ public function __construct(UrlGeneratorInterface $generator, Profiler $profiler
5454
*/
5555
public function homeAction()
5656
{
57-
if (null === $this->profiler) {
58-
throw new NotFoundHttpException('The profiler must be enabled.');
59-
}
60-
61-
$this->profiler->disable();
57+
$this->denyAccessIfProfilerDisabled();
6258

6359
return new RedirectResponse($this->generator->generate('_profiler_search_results', ['token' => 'empty', 'limit' => 10]), 302, ['Content-Type' => 'text/html']);
6460
}
@@ -75,11 +71,7 @@ public function homeAction()
7571
*/
7672
public function panelAction(Request $request, $token)
7773
{
78-
if (null === $this->profiler) {
79-
throw new NotFoundHttpException('The profiler must be enabled.');
80-
}
81-
82-
$this->profiler->disable();
74+
$this->denyAccessIfProfilerDisabled();
8375

8476
if (null !== $this->cspHandler) {
8577
$this->cspHandler->disableCsp();
@@ -170,11 +162,7 @@ public function toolbarAction(Request $request, $token)
170162
*/
171163
public function searchBarAction(Request $request)
172164
{
173-
if (null === $this->profiler) {
174-
throw new NotFoundHttpException('The profiler must be enabled.');
175-
}
176-
177-
$this->profiler->disable();
165+
$this->denyAccessIfProfilerDisabled();
178166

179167
if (null !== $this->cspHandler) {
180168
$this->cspHandler->disableCsp();
@@ -231,11 +219,7 @@ public function searchBarAction(Request $request)
231219
*/
232220
public function searchResultsAction(Request $request, $token)
233221
{
234-
if (null === $this->profiler) {
235-
throw new NotFoundHttpException('The profiler must be enabled.');
236-
}
237-
238-
$this->profiler->disable();
222+
$this->denyAccessIfProfilerDisabled();
239223

240224
if (null !== $this->cspHandler) {
241225
$this->cspHandler->disableCsp();
@@ -276,11 +260,7 @@ public function searchResultsAction(Request $request, $token)
276260
*/
277261
public function searchAction(Request $request)
278262
{
279-
if (null === $this->profiler) {
280-
throw new NotFoundHttpException('The profiler must be enabled.');
281-
}
282-
283-
$this->profiler->disable();
263+
$this->denyAccessIfProfilerDisabled();
284264

285265
$ip = preg_replace('/[^:\d\.]/', '', $request->query->get('ip'));
286266
$method = $request->query->get('method');
@@ -331,11 +311,7 @@ public function searchAction(Request $request)
331311
*/
332312
public function phpinfoAction()
333313
{
334-
if (null === $this->profiler) {
335-
throw new NotFoundHttpException('The profiler must be enabled.');
336-
}
337-
338-
$this->profiler->disable();
314+
$this->denyAccessIfProfilerDisabled();
339315

340316
if (null !== $this->cspHandler) {
341317
$this->cspHandler->disableCsp();
@@ -394,6 +370,15 @@ protected function getTemplateManager()
394370

395371
return $this->templateManager;
396372
}
373+
374+
private function denyAccessIfProfilerDisabled()
375+
{
376+
if (null === $this->profiler) {
377+
throw new NotFoundHttpException('The profiler must be enabled.');
378+
}
379+
380+
$this->profiler->disable();
381+
}
397382

398383
private function renderWithCspNonces(Request $request, $template, $variables, $code = 200, $headers = ['Content-Type' => 'text/html'])
399384
{

0 commit comments

Comments
 (0)
0