flarum / issue-archive

0 stars 0 forks source link

Translations unavailable in cli after cache clearing #100

Open luceos opened 3 years ago

luceos commented 3 years ago

Bug Report

Current Behavior

On current dev-master (post beta.16) when you php flarum cache:clear the storage/locale directory is cleared. When you now use the Translator by resolving it from ioc it can no longer use translations.

The reason for this is that:

  1. the service providers for Admin and Forum bind the Assets into ioc and there call AddTranslations for their specific frontend.
  2. through the AddTranslations the Locale Manager is resolved (causing extensions to load their files) and the catalogue to be cached to disk
  3. the console service provider has no logic at all related to this and as such is unable to restore the translations.

Understand that this bugs affects anything executed in cli, including scheduled tasks, cli command but also every single queue job that runs a non-default sync driver. Now usually this does not have a huge impact, because most forums regenerate their assets whenever the forum has visitors, but this will result in edge cases that are very hard to explain.

Steps to Reproduce

  1. run php flarum cache:clear
  2. create a command that uses the translator to parse a locale string
  3. See raw locale string instead of translation