[SecurityBundle] correct types for default arguments for firewall configs #34080
+3
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Up until now, the default template arguments in the
security.firewall.config
abstract service definition have been each defined (aside from the argument for$listeners
which is given acollection
type) in the XML as<argument />
which resolves to an empty string, despite that some of the arguments are typed to being either
bool
orarray|null
on theSymfony\Bundle\SecurityBundle\Security\FirewallConfig
class itself.This wouldn't be so much of a problem if the child definitions that use this as a template overrode all the arguments every time, but in the case of firewall configs that mark security as not being enabled, only the first few arguments are overwritten, so firewall config objects that do not have security enabled are instantiated by the DI container with parameters with some of the wrong types.
In general this wouldn't be an issue, as firewalls with security not enabled would not usually be consumed in a context where further security-related config were needed, but there is a case in
Symfony\Bundle\SecurityBundle\DataCollector\SecurityDataCollector
where the methodgetSwitchUser()
on the firewall config object can be called without checking first whether the firewall has security enabled, which leads to an exception being thrown:which is down to the firewall config being set with an empty string rather than
null
(in which case the logic here would function as expected).It seemed most appropriate as a fix (especially given possible introduction of scalar type hints in the future) to apply types to the default arguments so that it was no longer possible to instantiate a firewall config object with parameters of unexpected types.