-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] deprecate most characters in service ids #18028
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
Conversation
xabbuh
commented
Mar 6, 2016
Q | A |
---|---|
Branch | master |
Bug fix? | no |
New feature? | no |
BC breaks? | no |
Deprecations? | yes |
Tests pass? | yes |
Fixed tickets | #17801 |
License | MIT |
Doc PR | TODO |
@@ -601,6 +601,10 @@ public function setAliases(array $aliases) | |||
*/ | |||
public function setAlias($alias, $id) | |||
{ | |||
if (preg_match('/[^a-z0-9\._]/i', $alias)) { | |||
trigger_error(sprintf('Using characters other than A-Z, 0-9, ., and _ in service ids ("%s" given) is deprecated since Symfony 3.1 and will throw an exception in 4.0.', $alias), E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be silenced
524a810
to
b33c4ed
Compare
Comments addressed, tests fixed. Status: Needs Review |
@@ -163,6 +163,10 @@ public function setParameter($name, $value) | |||
*/ | |||
public function set($id, $service) | |||
{ | |||
if (preg_match('/[^a-z0-9\._%]/i', $id)) { | |||
@trigger_error(sprintf('Using characters other than A-Z, 0-9, ., and _ in service ids ("%s" given) is deprecated since Symfony 3.1 and will throw an exception in 4.0.', $id), E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of:
... and will throw an exception in 4.0.
We use this other wording in most deprecation notices:
... and will be removed in 4.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but that sounds really weird in this context (for example, in the Yaml component we used "will throw a ParseException" too).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. It makes sense. Thanks.
👍 Status: Reviewed |
should we allow non western users to use utf8 to name their services? I'm sure some do and I don't see anything wrong. wdyt? |
Can we make sure that non of them will cause trouble in the future? |
What do you think about allowing |
@xabbuh given the comments made by some reviewers (support non-English UTF8 chars, support slashes and backslashes, etc.) what do you think about switching to a blacklist filter instead of the current whitelist filter? Let's ban some concrete chars ( |
@javiereguiluz We could do that too. The list should then probably contain whitespace characters, control sequences, |
@xabbuh I can't think of anything else. Your list looks comprehensive. Thanks! |
1e1f353
to
097ae80
Compare
changed the PR to use a blacklist instead of a whitelist |
the whitelist should be built in a way where the generated method names for the dumping of the container generates a valid name (which means adding more stuff to the allowed whitelist). |
@stof isn't it possible to convert the services' id to another base to have only supported characters (maybe using Edit: at worst, if we really want to keep descriptive name as much as possible, we could solve the actual limitation of the dumper by having a counter which would be incremented each time a new unsupported service id is camelized. |
Can you take a look at #18167 please? |
097ae80
to
8bbb655
Compare
#18167 has been merged now |
8bbb655
to
d06bb91
Compare
rebased here ping @symfony/deciders |
What about deprecating an empty string as service id at the same time ? (see #18265 (comment)) |
@@ -31,13 +31,14 @@ public function testProcess($public) | |||
$definition = new Definition('%my-command.class%'); | |||
$definition->setPublic($public); | |||
$definition->addTag('console.command'); | |||
$container->setDefinition('my-command', $definition); | |||
$container->setDefinition('app.command', $definition); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get why we need to reject -
? Could we allow it?
Do we actually still need this ? |
Indeed, let's close this then. |