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

Skip to content

[3.0][Translator] changed the visibility of the locale from protected to private. #14693

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
Jun 18, 2015

Conversation

aitboudad
Copy link
Contributor

Q A
Bug fix? no
New feature? no
BC breaks? yes
Deprecations? yes
Fixed tickets ~
Tests pass? yes
License MIT

@mpdude
Copy link
Contributor

mpdude commented May 19, 2015

Thats something users will have to find in the 3.0 upgrade file, so no deprecation warning in earlier 2.x versions. Is that expected? (No idea how one could warn users, though...)

@aitboudad
Copy link
Contributor Author

@mpdude Not sure if there is a way to deprecate protected property the only thing came to my mind is to add a note in UPGRADE-2.8.md.

@linaori
Copy link
Contributor

linaori commented May 20, 2015

There's a way but you won't like it. Implement __get() which returns only the property required but also throws a deprecation notice.

@aitboudad
Copy link
Contributor Author

@iltar no it won't work as expected, the locale will be considered as public property.

@mpdude
Copy link
Contributor

mpdude commented May 20, 2015

The question is what the "Symfony standard way" of doing this looks like.

@hhamon
Copy link
Contributor

hhamon commented May 21, 2015

Does this BC break really add a value to the codebase? I mean, is it really worth it to take the risk of breaking applications / libraries relying on this $locale property?

@aitboudad
Copy link
Contributor Author

@hhamon making locale private can reduce the risk to use an invalid locale see setLocale and also I would prefer the public methods instead (setLocale, getLocale).

@aitboudad
Copy link
Contributor Author

ping @symfony/deciders

@aitboudad aitboudad force-pushed the translation_dep_locale_3 branch from 1eb844a to 9895c3d Compare June 18, 2015 10:57
@stof
Copy link
Member

stof commented Jun 18, 2015

and given that we added validations of invalid locales to avoid a security issue, forcing to go through the setter to update it seems logical to me.

👍

*/
public function setLocale($locale)
{
$this->locale = $locale;
Copy link
Contributor

Choose a reason for hiding this comment

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

why remove this tests? a custom translator can still return an invalid locale if it overwrites getLocale instead (or getLocale and setLocale).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted

@Tobion
Copy link
Contributor

Tobion commented Jun 18, 2015

I'm 👍 given that it usually doesn't make sense to make properties protected when there are public getters/setters also defined. There is no point it creating 2 extension points, esp. when it's security related.

@aitboudad aitboudad force-pushed the translation_dep_locale_3 branch from 9895c3d to 94de779 Compare June 18, 2015 12:29
@xabbuh
Copy link
Member

xabbuh commented Jun 18, 2015

👍

@fabpot
Copy link
Member

fabpot commented Jun 18, 2015

Thank you @aitboudad.

@fabpot fabpot merged commit 94de779 into symfony:master Jun 18, 2015
fabpot added a commit that referenced this pull request Jun 18, 2015
… from protected to private. (aitboudad)

This PR was merged into the 3.0-dev branch.

Discussion
----------

[3.0][Translator] changed the visibility of the locale from protected to private.

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | yes
| Deprecations? | yes
| Fixed tickets  | ~
| Tests pass?   | yes
| License       | MIT

Commits
-------

94de779 [Translator] changed the visibility of the locale from protected to private.
@aitboudad aitboudad deleted the translation_dep_locale_3 branch June 18, 2015 15:08
@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.

8 participants