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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix infinite loop while loading of languages #4254

Merged
merged 1 commit into from Mar 14, 2022
Merged

Fix infinite loop while loading of languages #4254

merged 1 commit into from Mar 14, 2022

Conversation

rabauss
Copy link
Contributor

@rabauss rabauss commented Mar 9, 2022

When upgrading to Contao 4.13 I got an infinite loop on all pages that loaded the languages with System::getLanguages().

The problem was, that my backend user had the legacy language de_DE - but I only realized that after the long analysis of this issue. And you cannot change the language because the backend profile page will also end up in an infinite loop 馃槩
By the way maybe an migration of the backend language of the users could make sense.

But it will also break the frontend if you use a non 2-letter language and have a frontend element which calls contao.intl.locales 馃憖

Because of #4043 the method getLocales is recursively called while loading the language files.
But the language is shortend shortly before in loadLanguageFile so you will get an infinite loop because of different $strCacheKey

foreach (self::getContainer()->get('contao.intl.locales')->getLocales($strLanguage) as $strLocale => $strLabel)

@Toflar Toflar requested review from ausi and leofeyer March 9, 2022 17:47
@Toflar Toflar added the bug label Mar 9, 2022
@Toflar Toflar added this to the 4.13 milestone Mar 9, 2022
@leofeyer leofeyer merged commit 35f255c into contao:4.13 Mar 14, 2022
@leofeyer
Copy link
Member

Thank you @rabauss.

@rabauss rabauss deleted the hotfix/languages branch March 14, 2022 16:36
leofeyer added a commit that referenced this pull request Mar 20, 2024
Description
-----------

Fixes #3803, #4254, ...

Something bad happened to me recently. I had a mailcious migration that did run forever. Because the migration was triggered by CI/CD, I had no control in stopping it... 馃檧

IMHO, there is no legitamte case (esp in prodution) where migrations need to run more than (lets say a random number) eight times. Therefore, this PR adds a maximum loop count. This PR fixes a range of potential errors, incl. concrete errors (see issue numbers above). 

(We might also consider to break the loop and return a command failure code).

Commits
-------

6cc2c91 Add loop control for migrations
c06528c Introduce local variable
5f3e30e Stop with error
8698970 Also write NDJSON
07fb02e Increase maximum iterations
ad0dd71 Update MigrateCommand.php
e453142 Update MigrateCommand.php
a6fd497 Adjust the error message

Co-authored-by: leofeyer <1192057+leofeyer@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants