-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] deprecate finding deep items in request parameters #16007
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
03ff6cb
to
be11681
Compare
@@ -88,6 +90,10 @@ public function add(array $parameters = array()) | |||
*/ | |||
public function get($path, $default = null, $deep = false) |
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.
IMO $path should be renamed to $key. It's not a path anymore when deep cannot/should not be used, esp. in 3.0 then.
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.
good idea
test failures are not related |
self::$propertyAccessor = PropertyAccess::createPropertyAccessor(); | ||
} | ||
|
||
return self::$propertyAccessor->getValue($value, substr($path, $pos)); |
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.
This will create exceptions if there is no value for the path. But it should instead return the default as previously in the deep logic. So you need to catch them.
be11681
to
2784cf4
Compare
try { | ||
return self::$propertyAccessor->getValue($value, substr($path, $pos)); | ||
} catch (AccessException $e) { | ||
return null; |
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.
return $default;
?
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.
Being able to pass a default value is useless as the code is only used internally by the Security HTTP component which does not have different default values. I removed this argument entirely.
2784cf4
to
845d573
Compare
$root = substr($path, 0, $pos); | ||
|
||
if (null === $value = $parameters->get($root)) { | ||
return null; |
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.
return;
is what we use in Symfony (same below).
👍 |
845d573
to
47fba88
Compare
Thank you @xabbuh. |
…st parameters (xabbuh) This PR was merged into the 2.8 branch. Discussion ---------- [HttpFoundation] deprecate finding deep items in request parameters | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | This is the same as #14203 but using the PropertyAccess component in the Security HTTP component to query nested request parameters and is rebased on the `2.8` branch. Commits ------- 47fba88 deprecate finding deep items in request parameters
Since symfony#16007, the Security HTTP component requires the PropertyAccess component to access nested parameter bag values. Since the Security component replaces the Security HTTP component, all dependencies of the replaced packages must be mirrored here.
…xabbuh) This PR was merged into the 2.8 branch. Discussion ---------- [Security] add dependency required by a replaced package | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Since #16007, the Security HTTP component requires the PropertyAccess component to access nested parameter bag values. Since the Security component replaces the Security HTTP component, all dependencies of the replaced packages must be mirrored here. Commits ------- d7034db add dependency required by a replaced package
This is the same as #14203 but using the PropertyAccess component in the Security HTTP component to query nested request parameters and is rebased on the
2.8
branch.