Skip to content
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

[Translator] Revert #1965, which break cache warmup for Symfony applications #2060

Merged
merged 1 commit into from
Aug 14, 2024

Conversation

Kocal
Copy link
Member

@Kocal Kocal commented Aug 13, 2024

Q A
Bug fix? yes
New feature? no
Issues Fix #2056
License MIT

Hi everyone!

It looks like we were too fast on #1965, and our tests base didn't see the issue.

With 2.19.0, people started to have issues with the CacheWarmer from UX Translator, which was... simply never called, and so the folder var/translations was not generated anymore.

In private, we've decided to revert the feature to fix the issue, and to re-open the discussion if necessary.

@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Aug 13, 2024
@SanderVerkuil
Copy link
Contributor

Yikes, this use case should've been found I recon. The interesting thing now is, that there are essentially two things (that appear to be conflicting). On the one hand, we have the issue mentioned in #2056 being caused by, what appears to be, people not having the translator service defined, and on the other hand #1962 where the translator is defined, but is being defined as the Identity translator, which causes the crash mentioned.

Wouldn't it be better to write a separate test-case that reproduces #2056 and fix that, while also still having the test passing for #1962? I'll see whether I can get a MR ready.

@smnandre
Copy link
Member

It appears no one has the translator service anymore, as @MatTheCat reported (and we reproduced the same thing with @kbond & @Kocal )

So we need to revert asap (this could impact apps in production)

We also realize we need to improve testing in the CI as we did not saw this coming.

One solution we talked about would be to pass a simple TranslatorInterface to the cachewarmer and exit early if this is not a TranslatorBagInterface

@SanderVerkuil
Copy link
Contributor

SanderVerkuil commented Aug 13, 2024

@smnandre I thought that might work as well, though the TranslatorBag does not extend/implement the TranslatorInterface. So when injecting the TranslatorInterface, it could be that it won't extend the TranslatorBag.

I'm currently trying to see whether I can remove the compiler pass, and make the TranslatorBag nullable/optional.

@smnandre But if the translator service is not available, how does the service('translator') method in the services.php find the correct dependency?

@smnandre
Copy link
Member

But if the translator service is not available, how does the service('translator') method in the services.php find the correct dependency?

That's what @MatTheCat explained in #2056

The culprit seems to be #1965: our translator service is an alias of translation.default, so TranslatorCompilerPass::hasValidTranslator returns false because ContainerBuilder::hasDefinition does not check aliases.

--

So when injecting the TranslatorInterface, it could be that it won't extend the TranslatorBag.

That would be the point. Warmer would only dump files if given a TranslatorInterface&TranslatorBagInterface

@SanderVerkuil
Copy link
Contributor

SanderVerkuil commented Aug 13, 2024

Ah alright, fair enought. I've created a separate MR that should fix it, by making the Translator nullable. See #2061, and please let me know whether this would be an appropriate fix.

@kbond
Copy link
Member

kbond commented Aug 14, 2024

Thanks Hugo.

@kbond kbond merged commit 0659a10 into symfony:2.x Aug 14, 2024
39 checks passed
kbond added a commit that referenced this pull request Aug 14, 2024
This PR was squashed before being merged into the 2.x branch.

Discussion
----------

[CI] Test ux.symfony.com with local UX packages

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Issues        | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT

<!--
Replace this notice by a description of your feature/bugfix.
This will help reviewers and should be a good start for the documentation.

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - For new features, provide some code snippets to help understand usage.
 - Features and deprecations must be submitted against branch main.
 - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
 - Never break backward compatibility (see https://symfony.com/bc).
-->

Following #1965 and #2060, I was a bit surprised to see ux.symfony.com tests were executed with UX packages coming from `2.x` branch, instead of UX packages from the same PR.

I believe doing this could help us for the future and prevent some regressions.

I've updated the script `.github/build-packages.php` to automatically replaces **all UX packages requires(-dev)** from all significant `composer.json` files from the repo:
<img width="1270" alt="image" src="https://github.com/user-attachments/assets/e04ff73f-7558-46cc-91e2-bf49c26a7f04">

Commits
-------

1386749 [CI] Test ux.symfony.com with local UX packages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug Fix Status: Reviewed Has been reviewed by a maintainer Translator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Translator] Cache is not warmed anymore
5 participants