Deprecate the special SYMFONY__ environment variables
This commit is contained in:
parent
c12727deb8
commit
e3362e854c
@ -187,6 +187,13 @@ HttpKernel
|
|||||||
which will tell the Kernel to use the response code set on the event's
|
which will tell the Kernel to use the response code set on the event's
|
||||||
response object.
|
response object.
|
||||||
|
|
||||||
|
* The `Kernel::getEnvParameters()` method has been deprecated and will be
|
||||||
|
removed in 4.0.
|
||||||
|
|
||||||
|
* The `SYMFONY__` environment variables have been deprecated and they will be
|
||||||
|
no longer processed automatically by Symfony in 4.0. Use the `%env()%` syntax
|
||||||
|
to get the value of any environment variable from configuration files instead.
|
||||||
|
|
||||||
Process
|
Process
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
@ -321,6 +321,12 @@ HttpKernel
|
|||||||
which will tell the Kernel to use the response code set on the event's
|
which will tell the Kernel to use the response code set on the event's
|
||||||
response object.
|
response object.
|
||||||
|
|
||||||
|
* The `Kernel::getEnvParameters()` method has been removed.
|
||||||
|
|
||||||
|
* The `SYMFONY__` environment variables are no longer processed automatically
|
||||||
|
by Symfony. Use the `%env()%` syntax to get the value of any environment
|
||||||
|
variable from configuration files instead.
|
||||||
|
|
||||||
Ldap
|
Ldap
|
||||||
----
|
----
|
||||||
|
|
||||||
|
@ -17,16 +17,6 @@ use Symfony\Component\Cache\Exception\InvalidArgumentException;
|
|||||||
|
|
||||||
class CachePoolsTest extends WebTestCase
|
class CachePoolsTest extends WebTestCase
|
||||||
{
|
{
|
||||||
protected function setUp()
|
|
||||||
{
|
|
||||||
$_SERVER['SYMFONY__REDIS_HOST'] = getenv('REDIS_HOST');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function tearDown()
|
|
||||||
{
|
|
||||||
unset($_SERVER['SYMFONY__REDIS_HOST']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCachePools()
|
public function testCachePools()
|
||||||
{
|
{
|
||||||
$this->doTestCachePools(array(), FilesystemAdapter::class);
|
$this->doTestCachePools(array(), FilesystemAdapter::class);
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
imports:
|
imports:
|
||||||
- { resource: ../config/default.yml }
|
- { resource: ../config/default.yml }
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
env(REDIS_HOST): 'localhost'
|
||||||
|
|
||||||
framework:
|
framework:
|
||||||
cache:
|
cache:
|
||||||
app: cache.adapter.redis
|
app: cache.adapter.redis
|
||||||
default_redis_provider: "redis://%redis_host%"
|
default_redis_provider: "redis://%env(REDIS_HOST)%"
|
||||||
pools:
|
pools:
|
||||||
cache.pool1:
|
cache.pool1:
|
||||||
public: true
|
public: true
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
imports:
|
imports:
|
||||||
- { resource: ../config/default.yml }
|
- { resource: ../config/default.yml }
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
env(REDIS_HOST): 'localhost'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
cache.test_redis_connection:
|
cache.test_redis_connection:
|
||||||
public: false
|
public: false
|
||||||
class: Redis
|
class: Redis
|
||||||
calls:
|
calls:
|
||||||
- [connect, ['%redis_host%']]
|
- [connect, ['%env(REDIS_HOST)%']]
|
||||||
|
|
||||||
cache.app:
|
cache.app:
|
||||||
parent: cache.adapter.redis
|
parent: cache.adapter.redis
|
||||||
|
@ -4,6 +4,8 @@ CHANGELOG
|
|||||||
3.3.0
|
3.3.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
* Deprecated `Kernel::getEnvParameters()`
|
||||||
|
* Deprecated the special `SYMFONY__` environment variables
|
||||||
* added the possibility to change the query string parameter used by `UriSigner`
|
* added the possibility to change the query string parameter used by `UriSigner`
|
||||||
* deprecated `LazyLoadingFragmentHandler::addRendererService()`
|
* deprecated `LazyLoadingFragmentHandler::addRendererService()`
|
||||||
* added `SessionListener`
|
* added `SessionListener`
|
||||||
|
@ -563,7 +563,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
|||||||
'kernel.charset' => $this->getCharset(),
|
'kernel.charset' => $this->getCharset(),
|
||||||
'kernel.container_class' => $this->getContainerClass(),
|
'kernel.container_class' => $this->getContainerClass(),
|
||||||
),
|
),
|
||||||
$this->getEnvParameters()
|
$this->getEnvParameters(false)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,12 +573,19 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
|||||||
* Only the parameters starting with "SYMFONY__" are considered.
|
* Only the parameters starting with "SYMFONY__" are considered.
|
||||||
*
|
*
|
||||||
* @return array An array of parameters
|
* @return array An array of parameters
|
||||||
|
*
|
||||||
|
* @deprecated since version 3.3, to be removed in 4.0
|
||||||
*/
|
*/
|
||||||
protected function getEnvParameters()
|
protected function getEnvParameters()
|
||||||
{
|
{
|
||||||
|
if (0 === func_num_args() || func_get_arg(0)) {
|
||||||
|
@trigger_error(sprintf('The %s() method is deprecated as of 3.3 and will be removed in 4.0. Use the %%env()%% syntax to get the value of any environment variable from configuration files instead.', __METHOD__), E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
foreach ($_SERVER as $key => $value) {
|
foreach ($_SERVER as $key => $value) {
|
||||||
if (0 === strpos($key, 'SYMFONY__')) {
|
if (0 === strpos($key, 'SYMFONY__')) {
|
||||||
|
@trigger_error(sprintf('The support of special environment variables that start with SYMFONY__ (such as "%s") is deprecated as of 3.3 and will be removed in 4.0. Use the %%env()%% syntax instead to get the value of environment variables in configuration files.', $key), E_USER_DEPRECATED);
|
||||||
$parameters[strtolower(str_replace('__', '.', substr($key, 9)))] = $value;
|
$parameters[strtolower(str_replace('__', '.', substr($key, 9)))] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -742,6 +742,25 @@ EOF;
|
|||||||
$this->assertEquals('_123', $kernel->getName());
|
$this->assertEquals('_123', $kernel->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
* @expectedDeprecation The Symfony\Component\HttpKernel\Kernel::getEnvParameters() method is deprecated as of 3.3 and will be removed in 4.0. Use the %cenv()%c syntax to get the value of any environment variable from configuration files instead.
|
||||||
|
* @expectedDeprecation The support of special environment variables that start with SYMFONY__ (such as "SYMFONY__FOO__BAR") is deprecated as of 3.3 and will be removed in 4.0. Use the %cenv()%c syntax instead to get the value of environment variables in configuration files.
|
||||||
|
*/
|
||||||
|
public function testSymfonyEnvironmentVariables()
|
||||||
|
{
|
||||||
|
$_SERVER['SYMFONY__FOO__BAR'] = 'baz';
|
||||||
|
|
||||||
|
$kernel = $this->getKernel();
|
||||||
|
$method = new \ReflectionMethod($kernel, 'getEnvParameters');
|
||||||
|
$method->setAccessible(true);
|
||||||
|
|
||||||
|
$envParameters = $method->invoke($kernel);
|
||||||
|
$this->assertSame('baz', $envParameters['foo.bar']);
|
||||||
|
|
||||||
|
unset($_SERVER['SYMFONY__FOO__BAR']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a mock for the BundleInterface.
|
* Returns a mock for the BundleInterface.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user