Skip to content

Conversation

@dsoriano
Copy link
Contributor

@dsoriano dsoriano commented Oct 6, 2025

This fix the issue #484

I removed the call of addDatabaseResources on the service initialization and manage it in the loadCatalogue call. With this there is no more errors with the Doctrine proxies because the cache generation is made when the catalogues are generated, not before.


protected function loadCatalogue(string $locale): void
{
if (!$this->isResourcesLoaded && ('all' === $this->options['resources_type'] || 'database' === $this->options['resources_type'])) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you capture $this->options['resources_type'] in a variable, your condition gets shorter

@bartmcleod
Copy link
Collaborator

@dsoriano Thank you for your MR! I ran the checks. The tests fail for php8.4, can you fix that? I added one suggestion to make your changes a tiny bit more readable, maybe you want to look into that as well?

@bartmcleod bartmcleod self-assigned this Oct 6, 2025
@dsoriano
Copy link
Contributor Author

dsoriano commented Oct 6, 2025

@bartmcleod sure, i'll take a look asap

@iitsGaMa
Copy link

iitsGaMa commented Oct 9, 2025

Well done @dsoriano and thank you for fixing this ! 👍

@bartmcleod bartmcleod merged commit 55876aa into lexik:master Oct 11, 2025
3 checks passed
@bartmcleod
Copy link
Collaborator

@dsoriano Thank you for your contribution!

@nicodemuz
Copy link

When I try to clear the cache using the button in the interface, it doesn't seem to work anymore after these changes:
image

if (!file_exists($this->cacheFile)) {
return true;
}

When executing the code, the $this>cacheFile becomes /var/www/path/to/project/symfony/var/cache/staging/database.resources.php, and no such file exists in my project. And therefore the cache will not be cleared anymore. Is this a bug in the code or a bug in my configuration? Does the cache clear feature work for anyone else?

I have configured the bundle with simply:

lexik_translation:
    fallback_locale: [en]
    managed_locales: [en, th]
    base_layout: "translation/lexik_layout.html.twig"

@bartmcleod
Copy link
Collaborator

@nicodemuz Can you specify reproduction steps so that we can know when to expect a cache file? Do you expect it to always be generated? Do we have a setting for that that you are aware of?

@dsoriano
Copy link
Contributor Author

dsoriano commented Dec 9, 2025

@nicodemuz yes your right, I discover this bug also this week. It's a problem I introduced in the configuration in the bundle. I had not time this week for a PR, next week I will take a look. As a quick fix you can override the configuration in your services.yaml with this :

    Lexik\Bundle\TranslationBundle\Translation\Translator:
        arguments:
            $container: '@service_container'
            $formatter: '@translator.formatter.default'
            $defaultLocale: '%kernel.default_locale%'
            $loaderIds: []
            $options:
                cache_dir: '%kernel.cache_dir%/translations'
                debug: '%kernel.debug%'
                resource_files: [ ]
                scanned_directories: [ ]
                cache_vary: [ ]

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants