Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection widget prototype fix #29547

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2a4e2e6
[Debug] Mark the ErrorHandler and ExceptionHandler classes as final
fancyweb Oct 22, 2018
bb6be15
[Validator] Checking a BIC along with an IBAN
sylfabre Oct 22, 2018
388840f
[Workflow] Trigger `entered` event for subject entering in the Workfl…
lyrixx Nov 8, 2018
534b83f
updated version to 4.3
fabpot Nov 26, 2018
0d35f97
Merge branch '4.2'
nicolas-grekas Nov 27, 2018
e343b66
Merge branch '4.2'
nicolas-grekas Nov 28, 2018
63c423a
Merge branch '4.2'
nicolas-grekas Nov 29, 2018
6da7afc
Merge branch '4.2'
nicolas-grekas Nov 30, 2018
5ba4997
Merge branch '4.2'
nicolas-grekas Nov 30, 2018
a928d2b
Merge branch '4.2'
nicolas-grekas Dec 1, 2018
905119b
feature #29145 [Workflow] Trigger `entered` event for subject enterin…
nicolas-grekas Dec 1, 2018
79162c1
[DomCrawler] Added return of element name in `extract()` method
Nov 7, 2018
4df912b
feature #29127 [DomCrawler] Added return of element name in `extract(…
nicolas-grekas Dec 1, 2018
aee4e33
[DI] Add a \"default\" EnvProcessor
jderusse Oct 25, 2018
67be665
feature #28976 [DI] Add a "default" EnvProcessor (jderusse)
nicolas-grekas Dec 1, 2018
397c19e
[DI] Deprecated using env vars with cannotBeEmpty()
ro0NL Oct 14, 2018
e695449
feature #28858 [DI] Deprecated using env vars with cannotBeEmpty() (r…
nicolas-grekas Dec 1, 2018
cc0be40
feature #28479 [Validator] Checking a BIC along with an IBAN (sylfabre)
nicolas-grekas Dec 1, 2018
ce6ecaf
Add upgrade from 4.2 to 4.3
ro0NL Dec 1, 2018
4cc14b4
Merge branch '4.2'
nicolas-grekas Dec 1, 2018
9771d8d
minor #29400 Add upgrade from 4.2 to 4.3 (ro0NL)
nicolas-grekas Dec 1, 2018
d63b3e3
fix merge
nicolas-grekas Dec 1, 2018
8aee36d
feature #28954 [Debug] Mark ErrorHandler and ExceptionHandler classes…
nicolas-grekas Dec 1, 2018
e0d9502
[DI] Fix deps=low
ro0NL Dec 1, 2018
0105562
minor #29401 [DI] Fix deps=low (ro0NL)
nicolas-grekas Dec 1, 2018
79b661d
Merge branch '4.2'
nicolas-grekas Dec 2, 2018
974b98b
Merge branch '4.2'
nicolas-grekas Dec 2, 2018
c7fe1b6
Merge branch '4.2'
nicolas-grekas Dec 3, 2018
e6fa538
Merge branch '4.2'
nicolas-grekas Dec 6, 2018
7011706
Avoid multiple rendering of collection prototypes
kagje Dec 6, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions UPGRADE-4.3.md
@@ -0,0 +1,7 @@
UPGRADE FROM 4.2 to 4.3
=======================

Config
------

* Deprecated using environment variables with `cannotBeEmpty()` if the value is validated with `validate()`
1 change: 1 addition & 0 deletions UPGRADE-5.0.md
Expand Up @@ -18,6 +18,7 @@ Config
* Added the `getChildNodeDefinitions()` method to `ParentNodeDefinitionInterface`.
* The `Processor` class has been made final
* Removed `FileLoaderLoadException`, use `LoaderLoadException` instead.
* Using environment variables with `cannotBeEmpty()` if the value is validated with `validate()` will throw an exception.

Console
-------
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -147,7 +147,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Doctrine/composer.json
Expand Up @@ -66,7 +66,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Monolog/composer.json
Expand Up @@ -46,7 +46,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/PhpUnit/composer.json
Expand Up @@ -40,7 +40,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
},
"thanks": {
"name": "phpunit/phpunit",
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/ProxyManager/composer.json
Expand Up @@ -35,7 +35,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
}
}
Expand Up @@ -28,7 +28,7 @@
{%- endblock form_widget_compound -%}

{%- block collection_widget -%}
{% if prototype is defined %}
{% if prototype is defined and prototype.rendered is same as(false) %}
{%- set attr = attr|merge({'data-prototype': form_row(prototype) }) -%}
{% endif %}
{{- block('form_widget') -}}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/composer.json
Expand Up @@ -70,7 +70,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/DebugBundle/composer.json
Expand Up @@ -44,7 +44,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/composer.json
Expand Up @@ -98,7 +98,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/SecurityBundle/composer.json
Expand Up @@ -64,7 +64,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/TwigBundle/composer.json
Expand Up @@ -54,7 +54,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/WebProfilerBundle/composer.json
Expand Up @@ -44,7 +44,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/WebServerBundle/composer.json
Expand Up @@ -37,7 +37,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/Asset/composer.json
Expand Up @@ -34,7 +34,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/BrowserKit/composer.json
Expand Up @@ -35,7 +35,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/composer.json
Expand Up @@ -51,7 +51,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
}
}
5 changes: 5 additions & 0 deletions src/Symfony/Component/Config/CHANGELOG.md
@@ -1,6 +1,11 @@
CHANGELOG
=========

4.3.0
-----

* deprecated using environment variables with `cannotBeEmpty()` if the value is validated with `validate()`

4.2.0
-----

Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Config/Definition/ScalarNode.php
Expand Up @@ -48,6 +48,8 @@ protected function validateType($value)
*/
protected function isValueEmpty($value)
{
// assume environment variables are never empty (which in practice is likely to be true during runtime)
// not doing so breaks many configs that are valid today
if ($this->isHandlingPlaceholder()) {
return false;
}
Expand Down
15 changes: 15 additions & 0 deletions src/Symfony/Component/Config/Definition/VariableNode.php
Expand Up @@ -81,6 +81,19 @@ protected function validateType($value)
*/
protected function finalizeValue($value)
{
// deny environment variables only when using custom validators
// this avoids ever passing an empty value to final validation closures
if (!$this->allowEmptyValue && $this->isHandlingPlaceholder() && $this->finalValidationClosures) {
@trigger_error(sprintf('Setting path "%s" to an environment variable is deprecated since Symfony 4.3. Remove "cannotBeEmpty()", "validate()" or include a prefix/suffix value instead.', $this->getPath()), E_USER_DEPRECATED);
// $e = new InvalidConfigurationException(sprintf('The path "%s" cannot contain an environment variable when empty values are not allowed by definition and are validated.', $this->getPath(), json_encode($value)));
// if ($hint = $this->getInfo()) {
// $e->addHint($hint);
// }
// $e->setPath($this->getPath());
//
// throw $e;
}

if (!$this->allowEmptyValue && $this->isValueEmpty($value)) {
$ex = new InvalidConfigurationException(sprintf('The path "%s" cannot contain an empty value, but got %s.', $this->getPath(), json_encode($value)));
if ($hint = $this->getInfo()) {
Expand Down Expand Up @@ -120,6 +133,8 @@ protected function mergeValues($leftSide, $rightSide)
* @param mixed $value
*
* @return bool
*
* @see finalizeValue()
*/
protected function isValueEmpty($value)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Config/composer.json
Expand Up @@ -41,7 +41,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/composer.json
Expand Up @@ -47,7 +47,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/CssSelector/composer.json
Expand Up @@ -31,7 +31,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
}
}
5 changes: 5 additions & 0 deletions src/Symfony/Component/Debug/CHANGELOG.md
@@ -1,6 +1,11 @@
CHANGELOG
=========

4.3.0
-----

* made the `ErrorHandler` and `ExceptionHandler` classes final

4.0.0
-----

Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Debug/ErrorHandler.php
Expand Up @@ -45,6 +45,8 @@
*
* @author Nicolas Grekas <p@tchwork.com>
* @author Grégoire Pineau <lyrixx@lyrixx.info>
*
* @final since Symfony 4.3
*/
class ErrorHandler
{
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Debug/ExceptionHandler.php
Expand Up @@ -26,6 +26,8 @@
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Nicolas Grekas <p@tchwork.com>
*
* @final since Symfony 4.3
*/
class ExceptionHandler
{
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Debug/composer.json
Expand Up @@ -34,7 +34,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
}
}
5 changes: 5 additions & 0 deletions src/Symfony/Component/DependencyInjection/CHANGELOG.md
@@ -1,6 +1,11 @@
CHANGELOG
=========

4.3.0
-----

* added `%env(default:...)%` processor to fallback to a default value

4.2.0
-----

Expand Down
31 changes: 26 additions & 5 deletions src/Symfony/Component/DependencyInjection/EnvVarProcessor.php
Expand Up @@ -43,6 +43,7 @@ public static function getProvidedTypes()
'json' => 'array',
'key' => 'bool|int|float|string|array',
'resolve' => 'string',
'default' => 'bool|int|float|string|array',
'string' => 'string',
);
}
Expand All @@ -56,7 +57,7 @@ public function getEnv($prefix, $name, \Closure $getEnv)

if ('key' === $prefix) {
if (false === $i) {
throw new RuntimeException(sprintf('Invalid configuration: env var "key:%s" does not contain a key specifier.', $name));
throw new RuntimeException(sprintf('Invalid env "key:%s": a key specifier should be provided.', $name));
}

$next = substr($name, $i + 1);
Expand All @@ -66,19 +67,39 @@ public function getEnv($prefix, $name, \Closure $getEnv)
if (!\is_array($array)) {
throw new RuntimeException(sprintf('Resolved value of "%s" did not result in an array value.', $next));
}
if (!array_key_exists($key, $array)) {
throw new RuntimeException(sprintf('Key "%s" not found in "%s" (resolved from "%s")', $key, json_encode($array), $next));

if (!isset($array[$key]) && !array_key_exists($key, $array)) {
throw new EnvNotFoundException(sprintf('Key "%s" not found in "%s" (resolved from "%s").', $key, json_encode($array), $next));
}

return $array[$key];
}

if ('default' === $prefix) {
if (false === $i) {
throw new RuntimeException(sprintf('Invalid env "default:%s": a fallback parameter should be provided.', $name));
}

$next = substr($name, $i + 1);
$default = substr($name, 0, $i);

if (!$this->container->hasParameter($default)) {
throw new RuntimeException(sprintf('Invalid env fallback in "default:%s": parameter "%s" not found.', $name, $default));
}

try {
return $getEnv($next);
} catch (EnvNotFoundException $e) {
return $this->container->getParameter($default);
}
}

if ('file' === $prefix) {
if (!is_scalar($file = $getEnv($name))) {
throw new RuntimeException(sprintf('Invalid file name: env var "%s" is non-scalar.', $name));
}
if (!file_exists($file)) {
throw new RuntimeException(sprintf('Env "file:%s" not found: %s does not exist.', $name, $file));
throw new EnvNotFoundException(sprintf('File "%s" not found (resolved from "%s").', $file, $name));
}

return file_get_contents($file);
Expand All @@ -94,7 +115,7 @@ public function getEnv($prefix, $name, \Closure $getEnv)
$env = $_SERVER[$name];
} elseif (false === ($env = getenv($name)) || null === $env) { // null is a possible value because of thread safety issues
if (!$this->container->hasParameter("env($name)")) {
throw new EnvNotFoundException($name);
throw new EnvNotFoundException(sprintf('Environment variable not found: "%s".', $name));
}

if (null === $env = $this->container->getParameter("env($name)")) {
Expand Down
Expand Up @@ -18,8 +18,4 @@
*/
class EnvNotFoundException extends InvalidArgumentException
{
public function __construct(string $name)
{
parent::__construct(sprintf('Environment variable not found: "%s".', $name));
}
}
Expand Up @@ -40,6 +40,7 @@ public function testSimpleProcessor()
'json' => array('array'),
'key' => array('bool', 'int', 'float', 'string', 'array'),
'resolve' => array('string'),
'default' => array('bool', 'int', 'float', 'string', 'array'),
'string' => array('string'),
);

Expand Down