Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Implemented possibility to skip key normalization in config processing #6086

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 1 commit into from

Conversation

lolautruche
Copy link
Contributor

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -
License of the code: MIT
Documentation PR: -

Description

This PR implements the possibility to deactivate explicitly config keys normalization as it's sometimes annoying and unexpected to have - transformed in _. The default behavior is kept and deactivation is possible at the DI extension level (not possible to do it at the node level since the config processor does key normalization globally).

@lsmith77
Copy link
Contributor

this is tricky since you might break some app config formats.

Semi related: I assume few people test their Bundles with anything but Yaml, but ATM the chances are quite good that it would also work with XML. then again many people are already not including the fix keys call so maybe we should also enable people to explicitly say which formats they support.

@stof
Copy link
Member

stof commented Nov 22, 2012

@lsmith77 you won't break anything as this PR is BC. You would brak it only if an existing bundle starts using it (and you are using XML)

@lsmith77
Copy link
Contributor

I wasn't trying to imply it breaks BC but it would likely mean that Bundles using this would break the assumption that all formats are supported.

@stof
Copy link
Member

stof commented Nov 22, 2012

@lsmith77 The only difference is that a bundle using that would have an XML config using underscores instead of dashes (which are the XML convention).
And btw, as long as you don't provide an XSD, people can already use the underscored tags in their XML config...

@lsmith77
Copy link
Contributor

right again. my point is that this feature breaks current assumptions. note I am not saying this should not be done either. just adding something to consider.

@lolautruche
Copy link
Contributor Author

Well, the real issue behind that is we currently don't know which format is used for application configuration, leading sometimes to unexpected issues. The problem is that the current fix is a bit brutal and magical, leading to headaches while debugging.
While a real way of dealing with config format should be the best way to fix this, allowing to throw an exception if the user format is inappropriate, this patch at least gives the opportunity to bypass this magical key normalization. A real solution should come with 2.2 or 2.3

@stof
Copy link
Member

stof commented Nov 22, 2012

Actually, this renaming of keys from dashes to underscores should probably be refactored to be aware of the tree. Because the only case where it causes some issues is for prototyped array nodes (using an associative array), as this is the only case where a key is defined by the user.

@lolautruche
Copy link
Contributor Author

@stof Exactly, and this is precisely where we have a problem, with prototyped array nodes. Having this key normalization aware of the tree is a nice option as well for a proper fix, but I think with this patch at least you can have some control 😃

@lolautruche
Copy link
Contributor Author

ping @fabpot

@lolautruche
Copy link
Contributor Author

Hello, any news on this ? Thanks

@fabpot
Copy link
Member

fabpot commented Dec 5, 2012

That can only be merged in master.

@lolautruche
Copy link
Contributor Author

@fabpot OK, should I open a new PR on master then ?

@fabpot
Copy link
Member

fabpot commented Dec 5, 2012

No, I'm going to switch the branch when merging, it was just to warn you about this.

@lolautruche
Copy link
Contributor Author

OK thanks 😃

@fabpot fabpot closed this in e925978 Dec 5, 2012
@fabpot fabpot mentioned this pull request Dec 15, 2012
fabpot added a commit that referenced this pull request Dec 16, 2012
This PR was merged into the master branch.

Commits
-------

6efae29 [TwigBundle] fixed configuration to avoid key normalizations for paths and globals (closes #5998)
e31d4f1 [Config] allowed the disabling of key normalization on some array nodes

Discussion
----------

Config key normalization

This is a quick proof-of-concept for a better fix of #6086, where key normalizations can be disabled on specific nodes. The previous patch was not really useful as you were only able to disable key normalization globally for a configuration.

ping @lolautruche

The second commit fixes #5998.

---------------------------------------------------------------------------

by lolautruche at 2012-12-15T15:39:00Z

+1
The approach is neat and much better than my workaround. Gives better control and avoids magic :smiley: (even if this *normalization* is still a bit obscure to me).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants