Skip to content

Enableable ArrayNodeDefinition is disabled for empty configuration #25789

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

Closed
wants to merge 4 commits into from

Conversation

mateuszsip
Copy link
Contributor

Q A
Branch? 2.7+
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #25760
License MIT

Fixes #25760.

Currently, documented behavior is not true:

* By default, the section is disabled. If any configuration is specified then
* the node will be automatically enabled:

@mateuszsip mateuszsip changed the base branch from master to 2.7 January 15, 2018 00:53
@@ -226,7 +226,9 @@ public function canBeEnabled()
->beforeNormalization()
->ifArray()
->then(function ($v) {
$v['enabled'] = isset($v['enabled']) ? $v['enabled'] : true;
if (!isset($v['enabled'])) {
$v['enabled'] = empty($v) ? false : true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can also be written as $v['enabled'] = !empty($v);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

damn, you're right :D

@xabbuh xabbuh added the Config label Jan 15, 2018
@xabbuh xabbuh added this to the 2.7 milestone Jan 15, 2018
Copy link
Contributor

@Simperfit Simperfit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests failure seems unrelated to the current PR.

@fabpot
Copy link
Member

fabpot commented Jan 17, 2018

Thank you @kejwmen.

fabpot added a commit that referenced this pull request Jan 17, 2018
…guration (kejwmen)

This PR was squashed before being merged into the 2.7 branch (closes #25789).

Discussion
----------

 Enableable ArrayNodeDefinition is disabled for empty configuration

| Q             | A
| ------------- | ---
| Branch?       | 2.7+
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #25760
| License       | MIT

Fixes #25760.

Currently, documented behavior is not true:

https://github.com/symfony/symfony/blob/70c8c2d47bd71861c8205985a17e68cedf828e1f/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php#L207-L208

Commits
-------

a6a330d  Enableable ArrayNodeDefinition is disabled for empty configuration
@fabpot fabpot closed this Jan 17, 2018
xabbuh added a commit to xabbuh/symfony that referenced this pull request Jan 19, 2018
The failing tests relied on the assets integration being enabled. Since
we never did enable this explicitly, the assets related definitions are
removed now that symfony#25789 was merged which fixed symfony#25760.
chalasr added a commit that referenced this pull request Jan 19, 2018
This PR was merged into the 3.3 branch.

Discussion
----------

[FrameworkBundle] fix DI extension tests

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

The failing tests relied on the assets integration being enabled. Since
we never did enable this explicitly, the assets related definitions are
removed now that #25789 was merged which fixed #25760.

Commits
-------

1cb8f69 [FrameworkBundle] fix DI extension tests
@fabpot
Copy link
Member

fabpot commented Jan 21, 2018

reverted because of #25862 (9312f79)

fabpot added a commit that referenced this pull request Jan 21, 2018
…ty configuration (kejwmen)"

This reverts commit 132cec4, reversing
changes made to d411301.
@@ -226,7 +226,9 @@ public function canBeEnabled()
->beforeNormalization()
->ifArray()
->then(function ($v) {
$v['enabled'] = isset($v['enabled']) ? $v['enabled'] : true;
if (!isset($v['enabled'])) {
$v['enabled'] = !empty($v);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be is_array($v) && !empty($v) to cover the foo: ~ case, which should work as enable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What tests should we add to make sure it won't happen in the future? Component tests cover null case already. ~ is just a null, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forget my comment. This callback is only triggered for arrays ;)

Copy link
Contributor Author

@mateuszsip mateuszsip Jan 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like ~ in yaml is represented by empty array (?), simple reproducer is available here

nicolas-grekas added a commit that referenced this pull request Jan 21, 2018
* 2.7:
  [HttpFoundation] fixed return type of method HeaderBag::get
  [HttpFoundation] Added "resource" type on Request::create docblock
  Revert "bug #25789  Enableable ArrayNodeDefinition is disabled for empty configuration (kejwmen)"
  Revert "bug #25851 [Validator] Conflict with egulias/email-validator 2.0 (emodric)"
  [Validator] add missing parent isset and add test
nicolas-grekas added a commit that referenced this pull request Jan 21, 2018
* 2.8:
  [HttpFoundation] fixed return type of method HeaderBag::get
  [HttpFoundation] Added "resource" type on Request::create docblock
  Revert "bug #25789  Enableable ArrayNodeDefinition is disabled for empty configuration (kejwmen)"
  Formatting fix in upgrade 3.0 document
  Revert "bug #25851 [Validator] Conflict with egulias/email-validator 2.0 (emodric)"
  [Validator] add missing parent isset and add test
nicolas-grekas added a commit that referenced this pull request Jan 21, 2018
* 3.3:
  Have weak_vendors ignore deprecations from outside
  [HttpFoundation] fixed return type of method HeaderBag::get
  [HttpFoundation] Added "resource" type on Request::create docblock
  [Process] Skip environment variables with false value in Process
  Revert "bug #25789  Enableable ArrayNodeDefinition is disabled for empty configuration (kejwmen)"
  Formatting fix in upgrade 3.0 document
  don't split lines on carriage returns when dumping
  Revert "bug #25851 [Validator] Conflict with egulias/email-validator 2.0 (emodric)"
  [DI] compilation perf tweak
  [Validator] Conflict with egulias/email-validator 2.0
  [Validator] add missing parent isset and add test
nicolas-grekas added a commit that referenced this pull request Jan 21, 2018
* 3.4:
  Have weak_vendors ignore deprecations from outside
  [HttpFoundation] fixed return type of method HeaderBag::get
  [HttpFoundation] Added "resource" type on Request::create docblock
  [Process] Skip environment variables with false value in Process
  Revert "bug #25789  Enableable ArrayNodeDefinition is disabled for empty configuration (kejwmen)"
  Formatting fix in upgrade 3.0 document
  don't split lines on carriage returns when dumping
  Revert "bug #25851 [Validator] Conflict with egulias/email-validator 2.0 (emodric)"
  [DI] compilation perf tweak
  [Validator] Conflict with egulias/email-validator 2.0
  [Validator] add missing parent isset and add test
nicolas-grekas added a commit that referenced this pull request Jan 21, 2018
* 4.0:
  Have weak_vendors ignore deprecations from outside
  [HttpFoundation] fixed return type of method HeaderBag::get
  [HttpFoundation] Added "resource" type on Request::create docblock
  [Console] Fix using finally where the catch can also fail
  [Process] Skip environment variables with false value in Process
  Revert "bug #25789  Enableable ArrayNodeDefinition is disabled for empty configuration (kejwmen)"
  Formatting fix in upgrade 3.0 document
  don't split lines on carriage returns when dumping
  trim spaces from unquoted scalar values
  Revert "bug #25851 [Validator] Conflict with egulias/email-validator 2.0 (emodric)"
  [DI] compilation perf tweak
  [Validator] Conflict with egulias/email-validator 2.0
  [Validator] add missing parent isset and add test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants