Navigation Menu

Skip to content

Commit

Permalink
feature #23728 [WebProfilerBundle] Removed the deprecated web_profile…
Browse files Browse the repository at this point in the history
…r.position option (javiereguiluz)

This PR was merged into the 4.0-dev branch.

Discussion
----------

[WebProfilerBundle] Removed the deprecated web_profiler.position option

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #23528
| License       | MIT
| Doc PR        | -

This PR shows the things we could remove if we accept #23528. If it's accepted, I'd create the PR for 3.4 deprecating the feature instead of removing it.

Commits
-------

cafdf2b [WebProfilerBundle] Deprecated the web_profiler.position option
  • Loading branch information
nicolas-grekas committed Sep 9, 2017
2 parents 8357f2a + cafdf2b commit 5d56791
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 88 deletions.
2 changes: 2 additions & 0 deletions src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md
Expand Up @@ -6,6 +6,8 @@ CHANGELOG

* removed the `WebProfilerExtension::dumpValue()` method
* removed the `getTemplates()` method of the `TemplateManager` class in favor of the ``getNames()`` method
* removed the `web_profiler.position` config option and the
`web_profiler.debug_toolbar.position` container parameter

3.1.0
-----
Expand Down
Expand Up @@ -34,28 +34,25 @@ class ProfilerController
private $profiler;
private $twig;
private $templates;
private $toolbarPosition;
private $cspHandler;
private $baseDir;

/**
* Constructor.
*
* @param UrlGeneratorInterface $generator The URL Generator
* @param Profiler $profiler The profiler
* @param Environment $twig The twig environment
* @param array $templates The templates
* @param string $toolbarPosition The toolbar position (top, bottom, normal, or null -- use the configuration)
* @param ContentSecurityPolicyHandler $cspHandler The Content-Security-Policy handler
* @param string $baseDir The project root directory
* @param UrlGeneratorInterface $generator The URL Generator
* @param Profiler $profiler The profiler
* @param Environment $twig The twig environment
* @param array $templates The templates
* @param ContentSecurityPolicyHandler $cspHandler The Content-Security-Policy handler
* @param string $baseDir The project root directory
*/
public function __construct(UrlGeneratorInterface $generator, Profiler $profiler = null, Environment $twig, array $templates, $toolbarPosition = 'bottom', ContentSecurityPolicyHandler $cspHandler = null, $baseDir = null)
public function __construct(UrlGeneratorInterface $generator, Profiler $profiler = null, Environment $twig, array $templates, ContentSecurityPolicyHandler $cspHandler = null, $baseDir = null)
{
$this->generator = $generator;
$this->profiler = $profiler;
$this->twig = $twig;
$this->templates = $templates;
$this->toolbarPosition = $toolbarPosition;
$this->cspHandler = $cspHandler;
$this->baseDir = $baseDir;
}
Expand Down Expand Up @@ -161,11 +158,6 @@ public function toolbarAction(Request $request, $token)
return new Response('', 404, array('Content-Type' => 'text/html'));
}

// the toolbar position (top, bottom, normal, or null -- use the configuration)
if (null === $position = $request->query->get('position')) {
$position = $this->toolbarPosition;
}

$url = null;
try {
$url = $this->generator->generate('_profiler', array('token' => $token));
Expand All @@ -175,7 +167,6 @@ public function toolbarAction(Request $request, $token)

return $this->renderWithCspNonces($request, '@WebProfiler/Profiler/toolbar.html.twig', array(
'request' => $request,
'position' => $position,
'profile' => $profile,
'templates' => $this->getTemplateManager()->getNames($profile),
'profiler_url' => $url,
Expand Down
Expand Up @@ -37,14 +37,6 @@ public function getConfigTreeBuilder()
$rootNode
->children()
->booleanNode('toolbar')->defaultFalse()->end()
->scalarNode('position')
->defaultValue('bottom')
->setDeprecated('The "web_profiler.position" configuration key has been deprecated in Symfony 3.4 and it will be removed in 4.0.')
->validate()
->ifNotInArray(array('bottom', 'top'))
->thenInvalid('The CSS position %s is not supported')
->end()
->end()
->booleanNode('intercept_redirects')->defaultFalse()->end()
->scalarNode('excluded_ajax_paths')->defaultValue('^/(app(_[\\w]+)?\\.php/)?_wdt')->end()
->end()
Expand Down
Expand Up @@ -44,11 +44,10 @@ public function load(array $configs, ContainerBuilder $container)

$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('profiler.xml');
$container->setParameter('web_profiler.debug_toolbar.position', $config['position']);

if ($config['toolbar'] || $config['intercept_redirects']) {
$loader->load('toolbar.xml');
$container->getDefinition('web_profiler.debug_toolbar')->replaceArgument(5, $config['excluded_ajax_paths']);
$container->getDefinition('web_profiler.debug_toolbar')->replaceArgument(4, $config['excluded_ajax_paths']);
$container->setParameter('web_profiler.debug_toolbar.intercept_redirects', $config['intercept_redirects']);
$container->setParameter('web_profiler.debug_toolbar.mode', $config['toolbar'] ? WebDebugToolbarListener::ENABLED : WebDebugToolbarListener::DISABLED);
}
Expand All @@ -66,7 +65,7 @@ public function load(array $configs, ContainerBuilder $container)
$baseDir = implode(DIRECTORY_SEPARATOR, $baseDir);

$profilerController = $container->getDefinition('web_profiler.controller.profiler');
$profilerController->replaceArgument(6, $baseDir);
$profilerController->replaceArgument(5, $baseDir);

$fileLinkFormatter = $container->getDefinition('debug.file_link_formatter');
$fileLinkFormatter->replaceArgument(2, $baseDir);
Expand Down
Expand Up @@ -40,17 +40,15 @@ class WebDebugToolbarListener implements EventSubscriberInterface
protected $urlGenerator;
protected $interceptRedirects;
protected $mode;
protected $position;
protected $excludedAjaxPaths;
private $cspHandler;

public function __construct(Environment $twig, $interceptRedirects = false, $mode = self::ENABLED, $position = 'bottom', UrlGeneratorInterface $urlGenerator = null, $excludedAjaxPaths = '^/bundles|^/_wdt', ContentSecurityPolicyHandler $cspHandler = null)
public function __construct(Environment $twig, $interceptRedirects = false, $mode = self::ENABLED, UrlGeneratorInterface $urlGenerator = null, $excludedAjaxPaths = '^/bundles|^/_wdt', ContentSecurityPolicyHandler $cspHandler = null)
{
$this->twig = $twig;
$this->urlGenerator = $urlGenerator;
$this->interceptRedirects = (bool) $interceptRedirects;
$this->mode = (int) $mode;
$this->position = $position;
$this->excludedAjaxPaths = $excludedAjaxPaths;
$this->cspHandler = $cspHandler;
}
Expand Down Expand Up @@ -124,7 +122,6 @@ protected function injectToolbar(Response $response, Request $request, array $no
$toolbar = "\n".str_replace("\n", '', $this->twig->render(
'@WebProfiler/Profiler/toolbar_js.html.twig',
array(
'position' => $this->position,
'excluded_ajax_paths' => $this->excludedAjaxPaths,
'token' => $response->headers->get('X-Debug-Token'),
'request' => $request,
Expand Down
Expand Up @@ -12,7 +12,6 @@
<argument type="service" id="profiler" on-invalid="null" />
<argument type="service" id="twig" />
<argument>%data_collector.templates%</argument>
<argument>%web_profiler.debug_toolbar.position%</argument>
<argument type="service" id="web_profiler.csp.handler" />
<argument>null</argument>
</service>
Expand Down
Expand Up @@ -10,13 +10,5 @@
<xsd:complexType name="config">
<xsd:attribute name="toolbar" type="xsd:boolean" />
<xsd:attribute name="intercept-redirects" type="xsd:boolean" />
<xsd:attribute name="position" type="positions" />
</xsd:complexType>

<xsd:simpleType name="positions">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="top"/>
<xsd:enumeration value="bottom"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
Expand Up @@ -12,7 +12,6 @@
<argument type="service" id="twig" />
<argument>%web_profiler.debug_toolbar.intercept_redirects%</argument>
<argument>%web_profiler.debug_toolbar.mode%</argument>
<argument>%web_profiler.debug_toolbar.position%</argument>
<argument type="service" id="router" on-invalid="ignore" />
<argument /> <!-- paths that should be excluded from the AJAX requests shown in the toolbar -->
<argument type="service" id="web_profiler.csp.handler" />
Expand Down
Expand Up @@ -416,34 +416,6 @@
display: none;
}

/* Override the setting when the toolbar is on the top */
{% if position == 'top' %}
.sf-minitoolbar {
border-bottom-left-radius: 4px;
border-top-left-radius: 0;
bottom: auto;
right: 0;
top: 0;
}

.sf-toolbarreset {
bottom: auto;
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
top: 0;
}

.sf-toolbar-block .sf-toolbar-info {
bottom: auto;
top: 36px;
}
{% endif %}

{% if not floatable %}
.sf-toolbarreset {
position: static;
}
{% endif %}

/* Responsive Design */
.sf-toolbar-icon .sf-toolbar-label,
.sf-toolbar-icon .sf-toolbar-value {
Expand Down
@@ -1,18 +1,10 @@
<div id="sfwdt{{ token }}" class="sf-toolbar sf-display-none"></div>
{{ include('@WebProfiler/Profiler/base_js.html.twig') }}
<style{% if csp_style_nonce %} nonce="{{ csp_style_nonce }}"{% endif %}>
{{ include('@WebProfiler/Profiler/toolbar.css.twig', { 'position': position, 'floatable': true }) }}
{{ include('@WebProfiler/Profiler/toolbar.css.twig') }}
</style>
<script{% if csp_script_nonce %} nonce={{ csp_script_nonce }}{% endif %}>/*<![CDATA[*/
(function () {
{% if 'top' == position %}
var sfwdt = document.getElementById('sfwdt{{ token }}');
document.body.insertBefore(
document.body.removeChild(sfwdt),
document.body.firstChild
);
{% endif %}
Sfjs.load(
'sfwdt{{ token }}',
'{{ path("_wdt", { "token": token }) }}',
Expand Down
Expand Up @@ -157,7 +157,7 @@ private function createController($profiler, $twig, $withCSP)
if ($withCSP) {
$nonceGenerator = $this->getMockBuilder('Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator')->getMock();

return new ProfilerController($urlGenerator, $profiler, $twig, array(), 'bottom', new ContentSecurityPolicyHandler($nonceGenerator));
return new ProfilerController($urlGenerator, $profiler, $twig, array(), new ContentSecurityPolicyHandler($nonceGenerator));
}

return new ProfilerController($urlGenerator, $profiler, $twig, array());
Expand Down
Expand Up @@ -32,12 +32,12 @@ public function testConfigTree($options, $results)
public function getDebugModes()
{
return array(
array(array(), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array('intercept_redirects' => true), array('intercept_redirects' => true, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array('intercept_redirects' => false), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array('toolbar' => true), array('intercept_redirects' => false, 'toolbar' => true, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array('position' => 'top'), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'top', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array('excluded_ajax_paths' => 'test'), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => 'test')),
array(array(), array('intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array('intercept_redirects' => true), array('intercept_redirects' => true, 'toolbar' => false, 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array('intercept_redirects' => false), array('intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array('toolbar' => true), array('intercept_redirects' => false, 'toolbar' => true, 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array(), array('intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array('excluded_ajax_paths' => 'test'), array('intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => 'test')),
);
}
}
Expand Up @@ -219,7 +219,7 @@ public function testXDebugUrlHeader()

$event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response);

$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, 'bottom', $urlGenerator);
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator);
$listener->onKernelResponse($event);

$this->assertEquals('http://mydomain.com/_profiler/xxxxxxxx', $response->headers->get('X-Debug-Token-Link'));
Expand All @@ -240,7 +240,7 @@ public function testThrowingUrlGenerator()

$event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response);

$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, 'bottom', $urlGenerator);
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator);
$listener->onKernelResponse($event);

$this->assertEquals('Exception: foo', $response->headers->get('X-Debug-Error'));
Expand All @@ -261,7 +261,7 @@ public function testThrowingErrorCleanup()

$event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response);

$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, 'bottom', $urlGenerator);
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator);
$listener->onKernelResponse($event);

$this->assertEquals('Exception: This multiline tabbed text should come out on a single plain line', $response->headers->get('X-Debug-Error'));
Expand Down

0 comments on commit 5d56791

Please sign in to comment.