Truly disabled profiler in prod
This commit is contained in:
parent
3c90abf2a2
commit
f675dd8faa
@ -91,7 +91,11 @@ class FrameworkExtension extends Extension
|
|||||||
$this->registerValidationConfiguration($config['validation'], $container, $loader);
|
$this->registerValidationConfiguration($config['validation'], $container, $loader);
|
||||||
$this->registerEsiConfiguration($config['esi'], $container, $loader);
|
$this->registerEsiConfiguration($config['esi'], $container, $loader);
|
||||||
$this->registerFragmentsConfiguration($config['fragments'], $container, $loader);
|
$this->registerFragmentsConfiguration($config['fragments'], $container, $loader);
|
||||||
$this->registerProfilerConfiguration($config['profiler'], $container, $loader);
|
|
||||||
|
if (isset($config['profiler']) && isset($config['profiler']['enabled']) && $config['profiler']['enabled']) {
|
||||||
|
$this->registerProfilerConfiguration($config['profiler'], $container, $loader);
|
||||||
|
}
|
||||||
|
|
||||||
$this->registerTranslatorConfiguration($config['translator'], $container);
|
$this->registerTranslatorConfiguration($config['translator'], $container);
|
||||||
|
|
||||||
if (isset($config['router'])) {
|
if (isset($config['router'])) {
|
||||||
|
@ -15,7 +15,6 @@ $container->loadFromExtension('framework', array(
|
|||||||
),
|
),
|
||||||
'profiler' => array(
|
'profiler' => array(
|
||||||
'only_exceptions' => true,
|
'only_exceptions' => true,
|
||||||
'enabled' => false,
|
|
||||||
),
|
),
|
||||||
'router' => array(
|
'router' => array(
|
||||||
'resource' => '%kernel.root_dir%/config/routing.xml',
|
'resource' => '%kernel.root_dir%/config/routing.xml',
|
||||||
|
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$container->loadFromExtension('framework', array(
|
||||||
|
'secret' => 's3cr3t',
|
||||||
|
'default_locale' => 'fr',
|
||||||
|
'form' => null,
|
||||||
|
'trust_proxy_headers' => true,
|
||||||
|
'trusted_proxies' => array('127.0.0.1', '10.0.0.1'),
|
||||||
|
'csrf_protection' => array(
|
||||||
|
'enabled' => true,
|
||||||
|
'field_name' => '_csrf',
|
||||||
|
),
|
||||||
|
'esi' => array(
|
||||||
|
'enabled' => true,
|
||||||
|
),
|
||||||
|
'profiler' => array(
|
||||||
|
'only_exceptions' => true,
|
||||||
|
'enabled' => false,
|
||||||
|
),
|
||||||
|
'router' => array(
|
||||||
|
'resource' => '%kernel.root_dir%/config/routing.xml',
|
||||||
|
'type' => 'xml',
|
||||||
|
),
|
||||||
|
'session' => array(
|
||||||
|
'storage_id' => 'session.storage.native',
|
||||||
|
'handler_id' => 'session.handler.native_file',
|
||||||
|
'name' => '_SYMFONY',
|
||||||
|
'lifetime' => 86400,
|
||||||
|
'path' => '/',
|
||||||
|
'domain' => 'example.com',
|
||||||
|
'secure' => true,
|
||||||
|
'httponly' => true,
|
||||||
|
'gc_maxlifetime' => 90000,
|
||||||
|
'gc_divisor' => 108,
|
||||||
|
'gc_probability' => 1,
|
||||||
|
'save_path' => '/path/to/sessions',
|
||||||
|
),
|
||||||
|
'templating' => array(
|
||||||
|
'assets_version' => 'SomeVersionScheme',
|
||||||
|
'assets_base_urls' => 'http://cdn.example.com',
|
||||||
|
'cache' => '/path/to/cache',
|
||||||
|
'engines' => array('php', 'twig'),
|
||||||
|
'loader' => array('loader.foo', 'loader.bar'),
|
||||||
|
'packages' => array(
|
||||||
|
'images' => array(
|
||||||
|
'version' => '1.0.0',
|
||||||
|
'base_urls' => array('http://images1.example.com', 'http://images2.example.com'),
|
||||||
|
),
|
||||||
|
'foo' => array(
|
||||||
|
'version' => '1.0.0',
|
||||||
|
),
|
||||||
|
'bar' => array(
|
||||||
|
'base_urls' => array('http://bar1.example.com', 'http://bar2.example.com'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'form' => array(
|
||||||
|
'resources' => array('theme1', 'theme2')
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'translator' => array(
|
||||||
|
'enabled' => true,
|
||||||
|
'fallback' => 'fr',
|
||||||
|
),
|
||||||
|
'validation' => array(
|
||||||
|
'enabled' => true,
|
||||||
|
'cache' => 'apc',
|
||||||
|
),
|
||||||
|
'annotations' => array(
|
||||||
|
'cache' => 'file',
|
||||||
|
'debug' => true,
|
||||||
|
'file_cache_dir' => '%kernel.cache_dir%/annotations',
|
||||||
|
),
|
||||||
|
'ide' => 'file%%link%%format'
|
||||||
|
));
|
@ -10,7 +10,7 @@
|
|||||||
<framework:csrf-protection enabled="true" field-name="_csrf" />
|
<framework:csrf-protection enabled="true" field-name="_csrf" />
|
||||||
<framework:form />
|
<framework:form />
|
||||||
<framework:esi enabled="true" />
|
<framework:esi enabled="true" />
|
||||||
<framework:profiler only-exceptions="true" enabled="false" />
|
<framework:profiler only-exceptions="true" />
|
||||||
<framework:router resource="%kernel.root_dir%/config/routing.xml" type="xml" />
|
<framework:router resource="%kernel.root_dir%/config/routing.xml" type="xml" />
|
||||||
<framework:session gc-maxlifetime="90000" gc-probability="1" gc-divisor="108" storage-id="session.storage.native" handler-id="session.handler.native_file" name="_SYMFONY" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="true" save-path="/path/to/sessions" />
|
<framework:session gc-maxlifetime="90000" gc-probability="1" gc-divisor="108" storage-id="session.storage.native" handler-id="session.handler.native_file" name="_SYMFONY" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="true" save-path="/path/to/sessions" />
|
||||||
<framework:templating assets-version="SomeVersionScheme" cache="/path/to/cache" >
|
<framework:templating assets-version="SomeVersionScheme" cache="/path/to/cache" >
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" ?>
|
||||||
|
|
||||||
|
<container xmlns="http://symfony.com/schema/dic/services"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||||
|
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||||
|
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||||
|
|
||||||
|
<framework:config secret="s3cr3t" ide="file%%link%%format" default-locale="fr" trust-proxy-headers="true" trusted-proxies="127.0.0.1, 10.0.0.1">
|
||||||
|
<framework:csrf-protection enabled="true" field-name="_csrf" />
|
||||||
|
<framework:form />
|
||||||
|
<framework:esi enabled="true" />
|
||||||
|
<framework:profiler only-exceptions="true" enabled="false" />
|
||||||
|
<framework:router resource="%kernel.root_dir%/config/routing.xml" type="xml" />
|
||||||
|
<framework:session gc-maxlifetime="90000" gc-probability="1" gc-divisor="108" storage-id="session.storage.native" handler-id="session.handler.native_file" name="_SYMFONY" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="true" save-path="/path/to/sessions" />
|
||||||
|
<framework:templating assets-version="SomeVersionScheme" cache="/path/to/cache" >
|
||||||
|
<framework:loader>loader.foo</framework:loader>
|
||||||
|
<framework:loader>loader.bar</framework:loader>
|
||||||
|
<framework:engine>php</framework:engine>
|
||||||
|
<framework:engine>twig</framework:engine>
|
||||||
|
<framework:assets-base-url>http://cdn.example.com</framework:assets-base-url>
|
||||||
|
<framework:package name="images" version="1.0.0">
|
||||||
|
<framework:base-url>http://images1.example.com</framework:base-url>
|
||||||
|
<framework:base-url>http://images2.example.com</framework:base-url>
|
||||||
|
</framework:package>
|
||||||
|
<framework:package name="foo" version="1.0.0" />
|
||||||
|
<framework:package name="bar">
|
||||||
|
<framework:base-url>http://bar1.example.com</framework:base-url>
|
||||||
|
<framework:base-url>http://bar2.example.com</framework:base-url>
|
||||||
|
</framework:package>
|
||||||
|
<framework:form>
|
||||||
|
<framework:resource>theme1</framework:resource>
|
||||||
|
<framework:resource>theme2</framework:resource>
|
||||||
|
</framework:form>
|
||||||
|
</framework:templating>
|
||||||
|
<framework:translator enabled="true" fallback="fr" />
|
||||||
|
<framework:validation enabled="true" cache="apc" />
|
||||||
|
<framework:annotations cache="file" debug="true" file-cache-dir="%kernel.cache_dir%/annotations" />
|
||||||
|
</framework:config>
|
||||||
|
</container>
|
@ -11,7 +11,6 @@ framework:
|
|||||||
enabled: true
|
enabled: true
|
||||||
profiler:
|
profiler:
|
||||||
only_exceptions: true
|
only_exceptions: true
|
||||||
enabled: false
|
|
||||||
router:
|
router:
|
||||||
resource: %kernel.root_dir%/config/routing.xml
|
resource: %kernel.root_dir%/config/routing.xml
|
||||||
type: xml
|
type: xml
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
framework:
|
||||||
|
secret: s3cr3t
|
||||||
|
default_locale: fr
|
||||||
|
form: ~
|
||||||
|
trust_proxy_headers: true
|
||||||
|
trusted_proxies: ['127.0.0.1', '10.0.0.1']
|
||||||
|
csrf_protection:
|
||||||
|
enabled: true
|
||||||
|
field_name: _csrf
|
||||||
|
esi:
|
||||||
|
enabled: true
|
||||||
|
profiler:
|
||||||
|
only_exceptions: true
|
||||||
|
enabled: false
|
||||||
|
router:
|
||||||
|
resource: %kernel.root_dir%/config/routing.xml
|
||||||
|
type: xml
|
||||||
|
session:
|
||||||
|
storage_id: session.storage.native
|
||||||
|
handler_id: session.handler.native_file
|
||||||
|
name: _SYMFONY
|
||||||
|
lifetime: 86400
|
||||||
|
path: /
|
||||||
|
domain: example.com
|
||||||
|
secure: true
|
||||||
|
httponly: true
|
||||||
|
gc_probability: 1
|
||||||
|
gc_divisor: 108
|
||||||
|
gc_maxlifetime: 90000
|
||||||
|
save_path: /path/to/sessions
|
||||||
|
templating:
|
||||||
|
assets_version: SomeVersionScheme
|
||||||
|
assets_base_urls: http://cdn.example.com
|
||||||
|
engines: [php, twig]
|
||||||
|
loader: [loader.foo, loader.bar]
|
||||||
|
cache: /path/to/cache
|
||||||
|
packages:
|
||||||
|
images:
|
||||||
|
version: 1.0.0
|
||||||
|
base_urls: ["http://images1.example.com", "http://images2.example.com"]
|
||||||
|
foo:
|
||||||
|
version: 1.0.0
|
||||||
|
bar:
|
||||||
|
base_urls: ["http://images1.example.com", "http://images2.example.com"]
|
||||||
|
form:
|
||||||
|
resources: [theme1, theme2]
|
||||||
|
translator:
|
||||||
|
enabled: true
|
||||||
|
fallback: fr
|
||||||
|
validation:
|
||||||
|
enabled: true
|
||||||
|
cache: apc
|
||||||
|
annotations:
|
||||||
|
cache: file
|
||||||
|
debug: true
|
||||||
|
file_cache_dir: %kernel.cache_dir%/annotations
|
||||||
|
ide: file%%link%%format
|
@ -62,9 +62,15 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
$this->assertTrue($container->hasDefinition('data_collector.config'), '->registerProfilerConfiguration() loads collectors.xml');
|
$this->assertTrue($container->hasDefinition('data_collector.config'), '->registerProfilerConfiguration() loads collectors.xml');
|
||||||
$this->assertTrue($container->getParameter('profiler_listener.only_exceptions'));
|
$this->assertTrue($container->getParameter('profiler_listener.only_exceptions'));
|
||||||
$this->assertEquals('%profiler_listener.only_exceptions%', $container->getDefinition('profiler_listener')->getArgument(2));
|
$this->assertEquals('%profiler_listener.only_exceptions%', $container->getDefinition('profiler_listener')->getArgument(2));
|
||||||
|
}
|
||||||
|
|
||||||
$calls = $container->getDefinition('profiler')->getMethodCalls();
|
public function testDisabledProfiler()
|
||||||
$this->assertEquals('disable', $calls[0][0]);
|
{
|
||||||
|
$container = $this->createContainerFromFile('full_disabled');
|
||||||
|
|
||||||
|
$this->assertFalse($container->hasDefinition('profiler'), '->registerProfilerConfiguration() does not load profiling.xml');
|
||||||
|
$this->assertFalse($container->hasDefinition('data_collector.config'), '->registerProfilerConfiguration() does not load collectors.xml');
|
||||||
|
$this->assertFalse($container->hasParameter('profiler_listener.only_exceptions'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRouter()
|
public function testRouter()
|
||||||
|
@ -33,7 +33,7 @@ class ProfilerTest extends WebTestCase
|
|||||||
$client->enableProfiler();
|
$client->enableProfiler();
|
||||||
$crawler = $client->request('GET', '/profiler');
|
$crawler = $client->request('GET', '/profiler');
|
||||||
$profile = $client->getProfile();
|
$profile = $client->getProfile();
|
||||||
$this->assertTrue(is_object($profile));
|
$this->assertFalse(is_object($profile));
|
||||||
|
|
||||||
$client->request('GET', '/profiler');
|
$client->request('GET', '/profiler');
|
||||||
$this->assertFalse($client->getProfile());
|
$this->assertFalse($client->getProfile());
|
||||||
|
@ -39,6 +39,10 @@ class WebProfilerExtension extends Extension
|
|||||||
*/
|
*/
|
||||||
public function load(array $configs, ContainerBuilder $container)
|
public function load(array $configs, ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
|
if (!$container->hasParameter('profiler.class')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$configuration = $this->getConfiguration($configs, $container);
|
$configuration = $this->getConfiguration($configs, $container);
|
||||||
$config = $this->processConfiguration($configuration, $configs);
|
$config = $this->processConfiguration($configuration, $configs);
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ class WebProfilerExtensionTest extends TestCase
|
|||||||
$this->container->setParameter('kernel.cache_dir', __DIR__);
|
$this->container->setParameter('kernel.cache_dir', __DIR__);
|
||||||
$this->container->setParameter('kernel.debug', false);
|
$this->container->setParameter('kernel.debug', false);
|
||||||
$this->container->setParameter('kernel.root_dir', __DIR__);
|
$this->container->setParameter('kernel.root_dir', __DIR__);
|
||||||
|
$this->container->setParameter('profiler.class', array('Symfony\\Component\\HttpKernel\\Profiler\\Profiler'));
|
||||||
$this->container->register('profiler', $this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\Profiler'))
|
$this->container->register('profiler', $this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\Profiler'))
|
||||||
->addArgument(new Definition($this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\ProfilerStorageInterface')));
|
->addArgument(new Definition($this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\ProfilerStorageInterface')));
|
||||||
$this->container->setParameter('data_collector.templates', array());
|
$this->container->setParameter('data_collector.templates', array());
|
||||||
|
Reference in New Issue
Block a user