Merge branch '3.4' into 4.1

* 3.4:
  Change button_widget class to btn-primary
  [Dotenv] dont use getenv() to read SYMFONY_DOTENV_VARS
  [HttpFoundation] Fixed PHP doc of ParameterBag::getBoolean
  [HttpFoundation] replace any preexisting Content-Type headers
This commit is contained in:
Nicolas Grekas 2018-11-08 22:55:44 +01:00
commit f45252a155
5 changed files with 17 additions and 10 deletions

View File

@ -149,6 +149,11 @@
{{- parent() -}}
{%- endblock button_widget %}
{% block submit_widget -%}
{%- set attr = attr|merge({class: (attr.class|default('btn-primary'))|trim}) -%}
{{- parent() -}}
{%- endblock submit_widget %}
{% block checkbox_widget -%}
{%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%}
{%- if 'checkbox-custom' in parent_label_class -%}

View File

@ -67,8 +67,8 @@ final class Dotenv
*/
public function populate(array $values): void
{
$loadedVars = array_flip(explode(',', getenv('SYMFONY_DOTENV_VARS')));
unset($loadedVars['']);
$updateLoadedVars = false;
$loadedVars = array_flip(explode(',', $_SERVER['SYMFONY_DOTENV_VARS'] ?? $_ENV['SYMFONY_DOTENV_VARS'] ?? '')));
foreach ($values as $name => $value) {
$notHttpName = 0 !== strpos($name, 'HTTP_');
@ -83,14 +83,15 @@ final class Dotenv
$_SERVER[$name] = $value;
}
$loadedVars[$name] = true;
if (!isset($loadedVars[$name])) {
$loadedVars[$name] = $updateLoadedVars = true;
}
}
if ($loadedVars) {
if ($updateLoadedVars) {
unset($loadedVars['']);
$loadedVars = implode(',', array_keys($loadedVars));
putenv("SYMFONY_DOTENV_VARS=$loadedVars");
$_ENV['SYMFONY_DOTENV_VARS'] = $loadedVars;
$_SERVER['SYMFONY_DOTENV_VARS'] = $loadedVars;
putenv('SYMFONY_DOTENV_VARS='.$_ENV['SYMFONY_DOTENV_VARS'] = $_SERVER['SYMFONY_DOTENV_VARS'] = $loadedVars);
}
}

View File

@ -268,7 +268,7 @@ class DotenvTest extends TestCase
public function testOverridingEnvVarsWithNamesMemorizedInSpecialVar()
{
putenv('SYMFONY_DOTENV_VARS=FOO,BAR,BAZ');
putenv('SYMFONY_DOTENV_VARS='.$_SERVER['SYMFONY_DOTENV_VARS'] = 'FOO,BAR,BAZ');
putenv('FOO=foo');
putenv('BAR=bar');

View File

@ -174,7 +174,7 @@ class ParameterBag implements \IteratorAggregate, \Countable
* Returns the parameter value converted to boolean.
*
* @param string $key The parameter key
* @param mixed $default The default value if the parameter key does not exist
* @param bool $default The default value if the parameter key does not exist
*
* @return bool The filtered value
*/

View File

@ -330,8 +330,9 @@ class Response
// headers
foreach ($this->headers->allPreserveCaseWithoutCookies() as $name => $values) {
$replace = 0 === strcasecmp($name, 'Content-Type');
foreach ($values as $value) {
header($name.': '.$value, false, $this->statusCode);
header($name.': '.$value, $replace, $this->statusCode);
}
}