diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
index 606677f38b4c2..b20ac793aaabe 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
@@ -93,7 +93,11 @@ public function load(array $configs, ContainerBuilder $container)
$this->registerValidationConfiguration($config['validation'], $container, $loader);
$this->registerEsiConfiguration($config['esi'], $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);
if (isset($config['router'])) {
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php
index 27988e2c2ef4c..8e314f9c709ae 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php
@@ -15,7 +15,6 @@
),
'profiler' => array(
'only_exceptions' => true,
- 'enabled' => false,
),
'router' => array(
'resource' => '%kernel.root_dir%/config/routing.xml',
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full_disabled.php
new file mode 100644
index 0000000000000..27988e2c2ef4c
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full_disabled.php
@@ -0,0 +1,74 @@
+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'
+));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml
index eacd416597baa..8dd22fd3b7824 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml
@@ -10,7 +10,7 @@
-
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full_disabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full_disabled.xml
new file mode 100644
index 0000000000000..eacd416597baa
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full_disabled.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ loader.foo
+ loader.bar
+ php
+ twig
+ http://cdn.example.com
+
+ http://images1.example.com
+ http://images2.example.com
+
+
+
+ http://bar1.example.com
+ http://bar2.example.com
+
+
+ theme1
+ theme2
+
+
+
+
+
+
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml
index 9eddd249d5b97..d8004f11b9402 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml
@@ -11,7 +11,6 @@ framework:
enabled: true
profiler:
only_exceptions: true
- enabled: false
router:
resource: %kernel.root_dir%/config/routing.xml
type: xml
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full_disabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full_disabled.yml
new file mode 100644
index 0000000000000..9eddd249d5b97
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full_disabled.yml
@@ -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
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
index 00c0098a0dda9..c463ea41da044 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
@@ -56,9 +56,15 @@ public function testProfiler()
$this->assertTrue($container->hasDefinition('data_collector.config'), '->registerProfilerConfiguration() loads collectors.xml');
$this->assertTrue($container->getParameter('profiler_listener.only_exceptions'));
$this->assertEquals('%profiler_listener.only_exceptions%', $container->getDefinition('profiler_listener')->getArgument(2));
+ }
+
+ public function testDisabledProfiler()
+ {
+ $container = $this->createContainerFromFile('full_disabled');
- $calls = $container->getDefinition('profiler')->getMethodCalls();
- $this->assertEquals('disable', $calls[0][0]);
+ $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()
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php
index d4eb927ff8213..6465272133ffb 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php
@@ -33,7 +33,7 @@ public function testProfilerIsDisabled($insulate)
$client->enableProfiler();
$crawler = $client->request('GET', '/profiler');
$profile = $client->getProfile();
- $this->assertTrue(is_object($profile));
+ $this->assertFalse(is_object($profile));
$client->request('GET', '/profiler');
$this->assertFalse($client->getProfile());
diff --git a/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php b/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php
index e4b4cb72a078d..57ec1c15b29f1 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php
@@ -39,6 +39,10 @@ class WebProfilerExtension extends Extension
*/
public function load(array $configs, ContainerBuilder $container)
{
+ if (!$container->hasParameter('profiler.class')) {
+ return;
+ }
+
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php
index 4169d495a1722..f9dd1eacd91c8 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php
@@ -61,6 +61,7 @@ protected function setUp()
$this->container->setParameter('kernel.cache_dir', __DIR__);
$this->container->setParameter('kernel.debug', false);
$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'))
->addArgument(new Definition($this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\ProfilerStorageInterface')));
$this->container->setParameter('data_collector.templates', array());