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

Skip to content

[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

Merged
merged 1 commit into from
Sep 30, 2015

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Sep 29, 2015

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.

@@ -88,6 +90,10 @@ public function add(array $parameters = array())
*/
public function get($path, $default = null, $deep = false)
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

good idea

@xabbuh
Copy link
Member Author

xabbuh commented Sep 29, 2015

test failures are not related

self::$propertyAccessor = PropertyAccess::createPropertyAccessor();
}

return self::$propertyAccessor->getValue($value, substr($path, $pos));
Copy link
Contributor

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.

try {
return self::$propertyAccessor->getValue($value, substr($path, $pos));
} catch (AccessException $e) {
return null;
Copy link

Choose a reason for hiding this comment

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

return $default;?

Copy link
Member Author

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.

$root = substr($path, 0, $pos);

if (null === $value = $parameters->get($root)) {
return null;
Copy link
Member

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).

@fabpot
Copy link
Member

fabpot commented Sep 30, 2015

👍

@fabpot
Copy link
Member

fabpot commented Sep 30, 2015

Thank you @xabbuh.

@fabpot fabpot merged commit 47fba88 into symfony:2.8 Sep 30, 2015
fabpot added a commit that referenced this pull request Sep 30, 2015
…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
@xabbuh xabbuh deleted the deprecate-deep-get branch September 30, 2015 10:06
xabbuh added a commit to xabbuh/symfony that referenced this pull request Sep 30, 2015
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.
fabpot added a commit that referenced this pull request Sep 30, 2015
…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
@fabpot fabpot mentioned this pull request Nov 16, 2015
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.

5 participants