Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| * lazily in loadResources() as well). | ||
| * | ||
| * @var array | ||
| */ |
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.
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 commentedJun 3, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Is loading the resources immediately in the constructor (here) really necessary (why)? Commenting it out does at least not break tests. |
mpdude commentedJun 8, 2017
@fabot /@nicolas-grekas does this look sensible? If you basically agree, I probably should rebase it onto 2.7. |
| */ | ||
| private$resourceLocales; | ||
| /** |
nicolas-grekasJun 8, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
typo: actual
let's rebase on 2.7 if it applies there
mpdude commentedJun 8, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Rebased onto 2.7; no modifications were necessary |
fabpot commentedJun 14, 2017
Thank you@mpdude. |
…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
jenkoian commentedNov 18, 2017
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 calling 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 call |
jenkoian commentedNov 21, 2017
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 commentedJan 11, 2018
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. |
Uh oh!
There was an error while loading.Please reload this page.
Fixes the bug reported in#23034:
When mixing
addResource()calls and providing theresource_filesoption, the order in which resources are loaded depends on thekernel.debugsetting 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.