Jmsserializerbundle: Warmup cache (new command?)

Created on 13 Jun 2019  路  6Comments  路  Source: schmittjoh/JMSSerializerBundle

Hi!

I know this was discussed in #415 and #611 before and rejected by @goetas with

Symfony is going to remove the cache:clear command since nobody was using it.... if you need to remove the cache.. just do rm -rf carchedir

As this never became reality I'd like to rediscuss this issue.

Here is the story:
I am managing an open source application and get the same bug reports over and over again, not only by users but also by experienced devs. My application fetches data from the built-in API to render stuff in the frontend. This data is not displayed, because the API responds with 500. This happens because the serializer tries to create files in the cache folder but fails due to wrong file permissions.

Now these permission issues are obviously not the problem of this bundle... but: this bundle is the only piece of the application that tries to write cache data after the cache was warmed-up.

Do you have any hint to solve this issue? I don't know anything about the bundles internals, but couldn't we use the metadata configuration to find all configured entities and pre-create the cache for them inside a cache-warmer?

I can work on a PR, but I would need some hints where to get started...

question

Most helpful comment

Worked like a snap, now the var/cache/dev/jms_serializer/ is filled during bin/console cache:warmup with a config like:

jms_serializer:
    metadata:
        warmup:
            paths:
                included:
                    - "%kernel.root_dir%/Entity/"
                    - "%kernel.root_dir%/API/Model/"
                excluded: []

Now where is the Sponsor button?

All 6 comments

Which version of the bundle are you using?

I guess you are using https://github.com/schmittjoh/JMSSerializerBundle/pull/615 and you are aware of https://github.com/schmittjoh/metadata/pull/72 .

Are you sure that all the metadata are pre generated?

No, what a shame ... I was just searching through the issues but missed the PR.
Thanks! I'll need some time to dig through the linked issues and get back with new information.

$ composer info jms/serializer-bundle
name     : jms/serializer-bundle
versions : * 3.3.0

:flushed: I have to blame myself for this issue. Back when I started the warmup config was not available. Seems I missed the change.
Here is the reference for the next person:
http://jmsyst.com/bundles/JMSSerializerBundle/master/configuration

Thanks @goetas for the friendly hints 馃憤

Worked like a snap, now the var/cache/dev/jms_serializer/ is filled during bin/console cache:warmup with a config like:

jms_serializer:
    metadata:
        warmup:
            paths:
                included:
                    - "%kernel.root_dir%/Entity/"
                    - "%kernel.root_dir%/API/Model/"
                excluded: []

Now where is the Sponsor button?

:) happy to see it worked!

Unfortunately github did not approve yet my sponsorship request, but you can find me on https://www.patreon.com/goetas

Mine is waiting as well. But you can still create .github/FUNDING.yml and link to your patreon in the meanwhile.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rgembalik picture rgembalik  路  3Comments

priestor picture priestor  路  12Comments

Chrysweel picture Chrysweel  路  7Comments

renan-taranto picture renan-taranto  路  5Comments

pdugas picture pdugas  路  9Comments