Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Translation][FrameworkBundle] Fix resource loading order inconsistency reported in #23034#23057

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
mpdude wants to merge5 commits intosymfony:2.7fromwebfactory:fix-23034

Conversation

@mpdude
Copy link
Contributor

@mpdudempdude commentedJun 3, 2017
edited
Loading

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#23034
LicenseMIT
Doc PR

Fixes the bug reported in#23034:

When mixingaddResource() calls and providing theresource_files option, the order in which resources are loaded depends on thekernel.debug setting and whether a cache is used.

In particular, when several loaders provide translations for the same message, the one that "wins" may change between development and production mode.

* lazily in loadResources() as well).
*
* @var array
*/
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Yes, using this array to collectaddResource() calls and actually execute them after theresource_files is ugly, but we don't have access to the private\Symfony\Component\Translation\Translator::$resources field so that we could "unshift" theresource_files in front of it inloadResources.

@mpdude
Copy link
ContributorAuthor

mpdude commentedJun 3, 2017
edited
Loading

Is loading the resources immediately in the constructor (here) really necessary (why)? Commenting it out does at least not break tests.

@mpdudempdude changed the title[Translator] Fix resource loading order inconsistency reported in #23034[Translation] Fix resource loading order inconsistency reported in #23034Jun 3, 2017
@mpdudempdude changed the title[Translation] Fix resource loading order inconsistency reported in #23034[Translation][FrameworkBundle] Fix resource loading order inconsistency reported in #23034Jun 3, 2017
@nicolas-grekasnicolas-grekas added this to the2.8 milestoneJun 4, 2017
@mpdude
Copy link
ContributorAuthor

@fabot /@nicolas-grekas does this look sensible? If you basically agree, I probably should rebase it onto 2.7.

*/
private$resourceLocales;

/**
Copy link
Member

@nicolas-grekasnicolas-grekasJun 8, 2017
edited
Loading

Choose a reason for hiding this comment

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

typo: actual
let's rebase on 2.7 if it applies there

mpdude reacted with thumbs up emoji
@mpdudempdude changed the base branch from2.8 to2.7June 8, 2017 08:26
@mpdude
Copy link
ContributorAuthor

mpdude commentedJun 8, 2017
edited
Loading

Rebased onto 2.7; no modifications were necessary

@fabpot
Copy link
Member

Thank you@mpdude.

@fabpotfabpot closed thisJun 14, 2017
fabpot added a commit that referenced this pull requestJun 14, 2017
…inconsistency reported in#23034 (mpdude)This PR was squashed before being merged into the 2.7 branch (closes#23057).Discussion----------[Translation][FrameworkBundle] Fix resource loading order inconsistency reported in#23034| Q             | A| ------------- | ---| Branch?       | 2.7| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#23034| License       | MIT| Doc PR        |Fixes the bug reported in#23034:When mixing `addResource()` calls and providing the `resource_files` option, the order in which resources are loaded depends on the `kernel.debug` setting and whether a cache is used.In particular, when several loaders provide translations for the same message, the one that "wins" may change between development and production mode.Commits-------2a9e65d [Translation][FrameworkBundle] Fix resource loading order inconsistency reported in#23034
@mpdudempdude deleted the fix-23034 branchJune 14, 2017 20:38
This was referencedJul 3, 2017
@jenkoian
Copy link
Contributor

My app has a custom loader to load translations from a REST service. This change broke it.

It broke because I was injecting the translator into the loader and callingaddResource from within it, thus callingaddResourceafter theinitialize method was called.

Now I suspect this is my error, injecting the translator into a loader certainly doesn't sound the right thing to do.

So I was just after confirmation that this is indeed my issue and any tips on the best way to load resources outside of the loader would be greatly received too. I initially thought a compiler pass, but I don't think it's as simple as that? i.e. I couldn't calladdMethodCall('addResource') for instance because I think that only works for an already constructed object.

@jenkoian
Copy link
Contributor

Note: I have now successfully used a compiler pass to work around this. Haveopened a PR though to highlight the BC break, may decide it's not a use case we need to support but it's there for deciders anyway 👍

@stof
Copy link
Member

Creating a circular reference between the translator and the loader to have the loader reconfiguring the translator regarding what resources should be loaded by the loader is indeed a use case we never intended to support.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

Assignees

No one assigned

Projects

None yet

Milestone

2.8

Development

Successfully merging this pull request may close these issues.

6 participants

@mpdude@fabpot@jenkoian@stof@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp