Skip to content

[Profiler][RFC] Allow to purge all profiles data from the profiler GUI #35146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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 @@ -63,6 +63,25 @@ public function homeAction()
return new RedirectResponse($this->generator->generate('_profiler_search_results', ['token' => 'empty', 'limit' => 10]), 302, ['Content-Type' => 'text/html']);
}

/**
* Purges all data from the storage.
*
* @return RedirectResponse A RedirectResponse instance
*
* @throws NotFoundHttpException
*/
public function purgeAction()
{
if (null === $this->profiler) {
throw new NotFoundHttpException('The profiler must be enabled.');
}

$this->profiler->disable();
$this->profiler->purge();

return new RedirectResponse($this->generator->generate('_profiler_search_results', ['token' => 'empty', 'limit' => 10]), 302, ['Content-Type' => 'text/html']);
}

/**
* Renders a profiler panel for the given token.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<default key="_controller">web_profiler.controller.profiler::homeAction</default>
</route>

<route id="_profiler_purge" path="/purge">
<default key="_controller">web_profiler.controller.profiler::purgeAction</default>
</route>

<route id="_profiler_search" path="/search">
<default key="_controller">web_profiler.controller.profiler::searchAction</default>
</route>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,9 @@
<div class="form-group">
<button type="submit" class="btn btn-sm">Search</button>
</div>

<div class="form-group">
<a href="{{ path('_profiler_purge') }}" class="btn btn-sm">Purge</a>
</div>
</form>
</div>