From 85058949883eee0b0deafbf5b090704adad28750 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Thu, 30 Nov 2017 23:22:28 -0500 Subject: [PATCH 1/8] Fix collision between view properties and form fields --- .../Bridge/Twig/Extension/FormExtension.php | 7 +++++++ .../views/Form/bootstrap_3_layout.html.twig | 4 ++-- .../views/Form/form_div_layout.html.twig | 4 ++-- .../views/Form/form_table_layout.html.twig | 2 +- .../Extension/FormExtensionDivLayoutTest.php | 16 ++++++++++++++++ 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Extension/FormExtension.php b/src/Symfony/Bridge/Twig/Extension/FormExtension.php index 053b1d4a6b..aaed8221c1 100644 --- a/src/Symfony/Bridge/Twig/Extension/FormExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/FormExtension.php @@ -14,6 +14,7 @@ namespace Symfony\Bridge\Twig\Extension; use Symfony\Bridge\Twig\TokenParser\FormThemeTokenParser; use Symfony\Bridge\Twig\Form\TwigRendererInterface; use Symfony\Component\Form\Extension\Core\View\ChoiceView; +use Symfony\Component\Form\FormView; use Twig\Environment; use Twig\Extension\AbstractExtension; use Twig\Extension\InitRuntimeInterface; @@ -97,6 +98,7 @@ class FormExtension extends AbstractExtension implements InitRuntimeInterface { return array( new TwigTest('selectedchoice', array($this, 'isSelectedChoice')), + new TwigTest('rootform', array($this, 'isRootForm')), ); } @@ -156,6 +158,11 @@ class FormExtension extends AbstractExtension implements InitRuntimeInterface return $choice->value === $selectedValue; } + public function isRootForm(FormView $formView) + { + return null === $formView->parent; + } + /** * {@inheritdoc} */ diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig index 2efc0c4d4a..e3c7634964 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig @@ -238,12 +238,12 @@ {% block form_errors -%} {% if errors|length > 0 -%} - {% if form.parent %}{% else %}
{% endif %} + {% if form is not rootform %}{% else %}
{% endif %}
    {%- for error in errors -%}
  • {{ error.message }}
  • {%- endfor -%}
- {% if form.parent %}{% else %}
{% endif %} + {% if form is not rootform %}
{% else %}
{% endif %} {%- endif %} {%- endblock form_errors %} diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig index a27c81dd49..ad00a502a0 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig @@ -15,7 +15,7 @@ {%- block form_widget_compound -%}
- {%- if form.parent is empty -%} + {%- if form is rootform -%} {{ form_errors(form) }} {%- endif -%} {{- block('form_rows') -}} @@ -303,7 +303,7 @@ {% endif %} {%- endfor %} - {% if not form.methodRendered and form.parent is null %} + {% if not form.methodRendered and form is rootform %} {%- do form.setMethodRendered() -%} {% set method = method|upper %} {%- if method in ["GET", "POST"] -%} diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/form_table_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/form_table_layout.html.twig index c7b3a4365b..39274c6c8d 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/form_table_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/form_table_layout.html.twig @@ -31,7 +31,7 @@ {%- block form_widget_compound -%} - {%- if form.parent is empty and errors|length > 0 -%} + {%- if form is rootform and errors|length > 0 -%}
{{- form_errors(form) -}} diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php index e2fbb48ce0..e11daf1831 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php @@ -146,6 +146,22 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest $this->assertSame($expected, $this->extension->isSelectedChoice($choice, $value)); } + public function isRootFormProvider() + { + return array( + array(true, new FormView()), + array(false, new FormView(new FormView())), + ); + } + + /** + * @dataProvider isRootFormProvider + */ + public function testIsRootForm($expected, FormView $formView) + { + $this->assertSame($expected, $this->extension->isRootForm($formView)); + } + protected function renderForm(FormView $view, array $vars = array()) { return (string) $this->extension->renderer->renderBlock($view, 'form', $vars); From c98d967b0ca6220b5aa690a27dffc10096fb9150 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 2 Dec 2017 11:31:36 +0100 Subject: [PATCH 2/8] [DI] turn $private to protected in dumped container, to make cache:clear BC --- .../Component/DependencyInjection/Dumper/PhpDumper.php | 8 ++++++-- .../Tests/Fixtures/php/services1-1.php | 6 +++++- .../DependencyInjection/Tests/Fixtures/php/services1.php | 6 +++++- .../DependencyInjection/Tests/Fixtures/php/services10.php | 6 +++++- .../DependencyInjection/Tests/Fixtures/php/services12.php | 6 +++++- .../DependencyInjection/Tests/Fixtures/php/services13.php | 6 +++++- .../DependencyInjection/Tests/Fixtures/php/services19.php | 6 +++++- .../DependencyInjection/Tests/Fixtures/php/services24.php | 6 +++++- .../DependencyInjection/Tests/Fixtures/php/services26.php | 6 +++++- .../DependencyInjection/Tests/Fixtures/php/services33.php | 6 +++++- .../DependencyInjection/Tests/Fixtures/php/services8.php | 6 +++++- .../Tests/Fixtures/php/services9_as_files.txt | 6 +++++- .../Tests/Fixtures/php/services9_compiled.php | 6 +++++- .../Fixtures/php/services_almost_circular_private.php | 6 +++++- .../Fixtures/php/services_almost_circular_public.php | 6 +++++- .../Tests/Fixtures/php/services_array_params.php | 6 +++++- .../Tests/Fixtures/php/services_base64_env.php | 6 +++++- .../Tests/Fixtures/php/services_env_in_id.php | 6 +++++- .../Tests/Fixtures/php/services_inline_requires.php | 6 +++++- .../Tests/Fixtures/php/services_locator.php | 6 +++++- .../Tests/Fixtures/php/services_private_frozen.php | 6 +++++- .../Tests/Fixtures/php/services_private_in_expression.php | 6 +++++- .../Tests/Fixtures/php/services_rot13_env.php | 6 +++++- .../Tests/Fixtures/php/services_subscriber.php | 6 +++++- .../Tests/Fixtures/php/services_uninitialized_ref.php | 6 +++++- 25 files changed, 126 insertions(+), 26 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index df7c0835d3..fa33fe8a8a 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -874,7 +874,11 @@ class $class extends $baseClass { private \$parameters; private \$targetDirs = array(); - private \$privates = array(); + + /*{$this->docStar} + * @internal but protected for BC on cache:clear + */ + protected \$privates = array(); public function __construct() { @@ -1058,7 +1062,7 @@ EOF; return $code." );\n"; } - private function addInlineRequires() :string + private function addInlineRequires(): string { if (!$this->hotPathTag || !$this->inlineRequires) { return ''; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php index cbc17d74df..a04d80affc 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php @@ -20,7 +20,11 @@ class Container extends \Symfony\Component\DependencyInjection\Dump\AbstractCont { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php index bb312436dc..f25c59b815 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php @@ -18,7 +18,11 @@ class ProjectServiceContainer extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php index ef88c48158..31c4475ec7 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php @@ -18,7 +18,11 @@ class ProjectServiceContainer extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php index 4a1fbb901c..9e193f5c9b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php @@ -18,7 +18,11 @@ class ProjectServiceContainer extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php index d17073ae0b..8c90280d27 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php @@ -18,7 +18,11 @@ class ProjectServiceContainer extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php index 80635ad02d..673c9d54bb 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php @@ -18,7 +18,11 @@ class ProjectServiceContainer extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php index baa8a5eeb2..090a77dd3c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php @@ -18,7 +18,11 @@ class ProjectServiceContainer extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php index 700275f1e6..2089bfe638 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php @@ -18,7 +18,11 @@ class Symfony_DI_PhpDumper_Test_EnvParameters extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php index 4ca6299d74..1c70b0ee8d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php @@ -18,7 +18,11 @@ class ProjectServiceContainer extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php index 0d60c3699c..dc7da1c274 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php @@ -18,7 +18,11 @@ class ProjectServiceContainer extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt index 579bf285ad..d3b0724d80 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt @@ -309,7 +309,11 @@ class ProjectServiceContainer extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php index 72e06b3416..0772d93ebe 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php @@ -18,7 +18,11 @@ class ProjectServiceContainer extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php index e8fdeb0d8a..4de6bfc233 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php @@ -18,7 +18,11 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Private extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php index 91b05f361a..79a0c11cc1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php @@ -18,7 +18,11 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Public extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php index cd7bc61ceb..0e4e9ea239 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php @@ -18,7 +18,11 @@ class ProjectServiceContainer extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php index 83aee3007b..8af802f70d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php @@ -18,7 +18,11 @@ class Symfony_DI_PhpDumper_Test_Base64Parameters extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php index b6afb3cf15..4100dcdd2b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php @@ -18,7 +18,11 @@ class ProjectServiceContainer extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php index 05bae36119..bc9a7a8d98 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php @@ -18,7 +18,11 @@ class ProjectServiceContainer extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php index b8aba31b1e..59bbce3a99 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php @@ -18,7 +18,11 @@ class ProjectServiceContainer extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php index 404944a336..86315e2eba 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php @@ -18,7 +18,11 @@ class ProjectServiceContainer extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php index efaa0fb1d9..5caf9104dd 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php @@ -18,7 +18,11 @@ class ProjectServiceContainer extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php index 61b0b72947..012a36023b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php @@ -18,7 +18,11 @@ class Symfony_DI_PhpDumper_Test_Rot13Parameters extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php index 934cad86b5..1c223c3e65 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php @@ -18,7 +18,11 @@ class ProjectServiceContainer extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php index 446d2ae482..0f5090c80b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php @@ -18,7 +18,11 @@ class Symfony_DI_PhpDumper_Test_Uninitialized_Reference extends Container { private $parameters; private $targetDirs = array(); - private $privates = array(); + + /** + * @internal but protected for BC on cache:clear + */ + protected $privates = array(); public function __construct() { From c9f72e2807762bd3a77d11fd4d413bc11c53a981 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 4 Dec 2017 13:50:51 +0100 Subject: [PATCH 3/8] [SecurityBundle] Fix compat with HttpFoundation >=3.4 --- .../Security/Factory/AbstractFactory.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php index d1b7980faa..39c73dc0c3 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php @@ -15,6 +15,7 @@ use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\HttpFoundation\Session\Storage\Handler\AbstractSessionHandler; /** * AbstractFactory is the base class for all classes inheriting from @@ -29,7 +30,7 @@ abstract class AbstractFactory implements SecurityFactoryInterface protected $options = array( 'check_path' => '/login_check', 'use_forward' => false, - 'require_previous_session' => true, + 'require_previous_session' => null, ); protected $defaultSuccessHandlerOptions = array( @@ -80,6 +81,10 @@ abstract class AbstractFactory implements SecurityFactoryInterface ->scalarNode('failure_handler')->end() ; + if (array_key_exists('require_previous_session', $this->options) && null === $this->options['require_previous_session']) { + $this->options['require_previous_session'] = !class_exists(AbstractSessionHandler::class); + } + foreach (array_merge($this->options, $this->defaultSuccessHandlerOptions, $this->defaultFailureHandlerOptions) as $name => $default) { if (is_bool($default)) { $builder->booleanNode($name)->defaultValue($default); From 888b48a89c7847d04a0a911ffc7e23f2e9b94131 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Mon, 4 Dec 2017 08:54:58 -0500 Subject: [PATCH 4/8] Fix collision between view properties and form fields --- .../Twig/Resources/views/Form/foundation_5_layout.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig index dc7bec9fb6..af9e658923 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig @@ -318,11 +318,11 @@ {% block form_errors -%} {% if errors|length > 0 -%} - {% if form.parent %}{% else %}
{% endif %} + {% if form is not rootform %}{% else %}
{% endif %} {%- for error in errors -%} {{ error.message }} {% if not loop.last %}, {% endif %} {%- endfor -%} - {% if form.parent %}{% else %}
{% endif %} + {% if form is not rootform %}
{% else %}
{% endif %} {%- endif %} {%- endblock form_errors %} From c330965cfbe6ef223330de6134668d3c1ad31cc9 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Mon, 4 Dec 2017 09:06:01 -0500 Subject: [PATCH 5/8] Fix collision between view properties and form fields --- .../Twig/Resources/views/Form/bootstrap_4_layout.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig index 96ca4be4d6..4e4e9facc3 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig @@ -173,7 +173,7 @@ {% block form_errors -%} {%- if errors|length > 0 -%} -
+
    {%- for error in errors -%}
  • {{ error.message }}
  • From b23b957ae9cc77eda71357b3f07dbaaf13691e01 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 4 Dec 2017 14:06:32 +0100 Subject: [PATCH 6/8] parse newlines in quoted multiline strings --- src/Symfony/Component/Yaml/Parser.php | 17 ++++++++++++++++- src/Symfony/Component/Yaml/Tests/ParserTest.php | 14 ++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 702df16f0a..a6e39007df 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -700,6 +700,8 @@ class Parser return Inline::parse($value, $flags, $this->refs); } + $lines = array(); + while ($this->moveToNextLine()) { // unquoted strings end before the first unindented line if (null === $quotation && 0 === $this->getCurrentLineIndentation()) { @@ -708,7 +710,7 @@ class Parser break; } - $value .= ' '.trim($this->currentLine); + $lines[] = trim($this->currentLine); // quoted string values end with a line that is terminated with the quotation character if ('' !== $this->currentLine && substr($this->currentLine, -1) === $quotation) { @@ -716,6 +718,19 @@ class Parser } } + for ($i = 0, $linesCount = count($lines), $previousLineBlank = false; $i < $linesCount; ++$i) { + if ('' === $lines[$i]) { + $value .= "\n"; + $previousLineBlank = true; + } elseif ($previousLineBlank) { + $value .= $lines[$i]; + $previousLineBlank = false; + } else { + $value .= ' '.$lines[$i]; + $previousLineBlank = false; + } + } + Inline::$parsedLineNumber = $this->getRealCurrentLineNb(); $parsedValue = Inline::parse($value, $flags, $this->refs); diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 7a3c405714..1d35ecc1bd 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -1572,6 +1572,20 @@ YAML; $this->assertSame($expected, $this->parser->parse($yaml)); } + public function testBlankLinesInQuotedMultiLineString() + { + $yaml = << "foo\nbar", + ); + + $this->assertSame($expected, $this->parser->parse($yaml)); + } + public function testParseMultiLineUnquotedString() { $yaml = << Date: Mon, 4 Dec 2017 16:10:11 +0100 Subject: [PATCH 7/8] [DI] Fix deep-inlining of non-shared refs --- .../Compiler/InlineServiceDefinitionsPass.php | 44 ++++++++++++--- .../InlineServiceDefinitionsPassTest.php | 54 +++++++++++++++++++ 2 files changed, 90 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php index ff9ac315b0..8eb6e94d24 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php @@ -13,6 +13,7 @@ namespace Symfony\Component\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\Argument\ArgumentInterface; use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException; use Symfony\Component\DependencyInjection\Reference; /** @@ -23,6 +24,7 @@ use Symfony\Component\DependencyInjection\Reference; class InlineServiceDefinitionsPass extends AbstractRecursivePass implements RepeatablePassInterface { private $repeatedPass; + private $cloningIds = array(); private $inlinedServiceIds = array(); /** @@ -54,18 +56,44 @@ class InlineServiceDefinitionsPass extends AbstractRecursivePass implements Repe // Reference found in ArgumentInterface::getValues() are not inlineable return $value; } - if ($value instanceof Reference && $this->container->hasDefinition($id = (string) $value)) { - $definition = $this->container->getDefinition($id); - if ($this->isInlineableDefinition($id, $definition, $this->container->getCompiler()->getServiceReferenceGraph())) { - $this->container->log($this, sprintf('Inlined service "%s" to "%s".', $id, $this->currentId)); - $this->inlinedServiceIds[$id][] = $this->currentId; - - return $definition->isShared() ? $definition : clone $definition; + if ($value instanceof Definition && $this->cloningIds) { + if ($value->isShared()) { + return $value; } + $value = clone $value; } - return parent::processValue($value, $isRoot); + if (!$value instanceof Reference || !$this->container->hasDefinition($id = (string) $value)) { + return parent::processValue($value, $isRoot); + } + + $definition = $this->container->getDefinition($id); + + if (!$this->isInlineableDefinition($id, $definition, $this->container->getCompiler()->getServiceReferenceGraph())) { + return $value; + } + + $this->container->log($this, sprintf('Inlined service "%s" to "%s".', $id, $this->currentId)); + $this->inlinedServiceIds[$id][] = $this->currentId; + + if ($definition->isShared()) { + return $definition; + } + + if (isset($this->cloningIds[$id])) { + $ids = array_keys($this->cloningIds); + $ids[] = $id; + + throw new ServiceCircularReferenceException($id, array_slice($ids, array_search($id, $ids))); + } + + $this->cloningIds[$id] = true; + try { + return $this->processValue($definition); + } finally { + unset($this->cloningIds[$id]); + } } /** diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php index 09e4913664..365c16c2d2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php @@ -111,6 +111,60 @@ class InlineServiceDefinitionsPassTest extends TestCase $this->assertEquals($container->getDefinition('foo')->getArgument(0), $container->getDefinition('bar')); } + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException + * @expectedExceptionMessage Circular reference detected for service "bar", path: "bar -> foo -> bar". + */ + public function testProcessThrowsOnNonSharedLoops() + { + $container = new ContainerBuilder(); + $container + ->register('foo') + ->addArgument(new Reference('bar')) + ->setShared(false) + ; + $container + ->register('bar') + ->setShared(false) + ->addMethodCall('setFoo', array(new Reference('foo'))) + ; + + $this->process($container); + } + + public function testProcessNestedNonSharedServices() + { + $container = new ContainerBuilder(); + $container + ->register('foo') + ->addArgument(new Reference('bar1')) + ->addArgument(new Reference('bar2')) + ; + $container + ->register('bar1') + ->setShared(false) + ->addArgument(new Reference('baz')) + ; + $container + ->register('bar2') + ->setShared(false) + ->addArgument(new Reference('baz')) + ; + $container + ->register('baz') + ->setShared(false) + ; + + $this->process($container); + + $baz1 = $container->getDefinition('foo')->getArgument(0)->getArgument(0); + $baz2 = $container->getDefinition('foo')->getArgument(1)->getArgument(0); + + $this->assertEquals($container->getDefinition('baz'), $baz1); + $this->assertEquals($container->getDefinition('baz'), $baz2); + $this->assertNotSame($baz1, $baz2); + } + public function testProcessInlinesIfMultipleReferencesButAllFromTheSameDefinition() { $container = new ContainerBuilder(); From 17d84f6a873aa50c460bb7844dff97b630f42a6a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 4 Dec 2017 17:04:41 +0100 Subject: [PATCH 8/8] [DI] Fix missing unset leading to false-positive circular ref --- src/Symfony/Component/DependencyInjection/Container.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index 681ddc7024..14af37ef78 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -298,6 +298,7 @@ class Container implements ResettableContainerInterface } elseif (isset($this->methodMap[$id])) { return self::IGNORE_ON_UNINITIALIZED_REFERENCE === $invalidBehavior ? null : $this->{$this->methodMap[$id]}(); } elseif (--$i && $id !== $normalizedId = $this->normalizeId($id)) { + unset($this->loading[$id]); $id = $normalizedId; continue; } elseif (!$this->methodMap && !$this instanceof ContainerBuilder && __CLASS__ !== static::class && method_exists($this, $method = 'get'.strtr($id, $this->underscoreMap).'Service')) {