PdfBundle icon indicating copy to clipboard operation
PdfBundle copied to clipboard

Unable to run clear:cache in development mode

Open d3vpunk opened this issue 11 years ago • 7 comments

It's not possible to clear the cache of my symfony2 application. The PdfBundle internally uses some zf_cache with www-data rights (the user linux uses when you run your application in the browser. In the console, you run the app/console with another user who is not able to delete the folder:

So it's not possible to delete the cache folder:

[UnexpectedValueException] FilesystemIterator::__construct(/app/cache/dev_old/zfcache-fa): failed to open dir: Permission denied

d3vpunk avatar Aug 26 '13 09:08 d3vpunk

This is not PdfBundle issue but general symfony2 problem. Symfony2 cache is precreated by user who called app/console script but application runs on www-data account, so when some cache is creating while application runtime, permission denied error occurs.

There are some solutions: http://symfony.com/doc/current/book/installation.html#configuration-and-setup

I use umask function in first line of console script and app*.php files and it works ok.

psliwa avatar Aug 26 '13 09:08 psliwa

Thanks for the fast reaction and this great bundle!

I know this solution but i think this not an elegant one. I read the your documentation and i'm apparently able to define cache options: https://github.com/psliwa/PdfBundle#configuration

I tried to define some zend cache related cache options but it didn't work for me: http://framework.zend.com/manual/1.12/en/zend.cache.backends.html

Isn't it possible to define some symfony2 friendly caching options as an intiial configuration of the bundle?

d3vpunk avatar Aug 27 '13 12:08 d3vpunk

In a shared host prod environment umask() (as suggested above) does not prevent an error on cache:clear similar to that of playr1983g.

truckee avatar Nov 10 '13 19:11 truckee

Probably you set this mask after cache was created. Umask doesn't work if cache is already created. You should clear cache one time manually (via delete cache/prod directory) and next time cache:clear should work ok.

psliwa avatar Nov 11 '13 15:11 psliwa

Piotr,

Thanks for your reply.  Such does not appear to be the case.  I removed the app/cache/prod directory, ran clear cache for prod environment command as user then created a pdf in prod environment.  The zfcache* directories return owned by www-data with no group or world rights.

Now trying (without much success) to create a controller to clear cache for prod environment.

George

UPDATE: Now that I have a controller that can deal with the prod cache I no longer worry about www-data owned directories.

I very much appreciate your work here. I apologize for not being able to contribute - my work is as a volunteer for a non-profit.


From: Piotr Śliwa [email protected] To: psliwa/PdfBundle [email protected] Cc: truckee [email protected] Sent: Monday, November 11, 2013 7:15 AM Subject: Re: [PdfBundle] Unable to run clear:cache in development mode (#38)

Probably you set this mask after cache was created. Umask doesn't work if cache is already created. You should clear cache one time manually (via delete cache/prod directory) and next time cache:clear should work ok. — Reply to this email directly or view it on GitHub.

truckee avatar Nov 11 '13 16:11 truckee

Hi,

Problem hasn't been resolved yet, unfortunately. Still having issues with this. I keep changing the access rights to the cache folder due to the zf-cache dirs. Is there going to be a solution for this in the near future?

Best regards, Rico

ricohumme avatar Mar 12 '15 10:03 ricohumme

Hi to the best pdf library.

In my case setting right permissions for zfcache library helped:

ps_pdf:
    ...
    cache:
        type: ~
        options:
            filePermission: 0660
            dirPermission: 0770
    ...

Using symfony 3.4, Best regards, Bart

bnlab avatar Jun 07 '18 08:06 bnlab