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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

artisan cache:clear silently fails if cache files are not writable #1179

Closed
d13r opened this issue May 4, 2013 · 10 comments
Closed

artisan cache:clear silently fails if cache files are not writable #1179

d13r opened this issue May 4, 2013 · 10 comments

Comments

@d13r
Copy link
Contributor

d13r commented May 4, 2013

Using the "file" cache driver, my cache files are owned by the web server user (www-data) and not writable by me, but artisan cache:clear still says "Application cache cleared!", giving no indication that it actually failed.

@jasonlewis
Copy link
Contributor

The cache:clear command clears the applications services.json file, not the app/storage/cache directory. Check to see if that file is being deleted.

@taylorotwell
Copy link
Member

Jason, I'm pretty sure cache:clear deletes the app/storage/cache if
you're using the file driver.

@jasonlewis
Copy link
Contributor

Oh yeah, it does, I totally overlooked that first line. 😉 (Still waking up!)

However, the cache stores don't return a boolean for success or failure.

@taylorotwell
Copy link
Member

Eh, just going to close this for now. Don't see it as very critical as probably isn't totally worth the time to fix at the moment.

@mabasic
Copy link

mabasic commented Apr 17, 2016

This just happened to me last night. I'm trying to figure out where in code does the cache actually delete the files from filesystem ... it seems like a simple thing to fix, if only I could locate the file xD

Found it, going to create a PR once fixed.

Found the issue, but don't know how to properly fix it because things need to be changed a little.

Let me take you step by step on this one:

The problem is when the Cache calls flush method on FileStore cache store. It then calls deleteDirectory method which just assumes that deleting files and directories from that directory went good. When in fact it didn't.

This line here just ignores output from delete method which in fact tries to delete a file and return false or true if it succedes or fails.

Possible solution:

  • In deleteDirectory method check if file deletion fails and return false or a list of files not deleted or an exception or some kind of feedback.
  • Then in FileStore flush method check the output of deleteDirectory and return boolean.
  • Finally in clear:cache command check the output of flush method and depending on that display error to user on console

Possible hiccup:

I have found a contract for Store where it says that flush() method should return void.

Maybe implementing this change would mean that other cache stores would need to implement boolean as a return value on flush method.

What do you think?

@jfelipeara
Copy link

i'm having the same issue right now @davejamesmiller did you manage to solve the issue?

@d13r
Copy link
Contributor Author

d13r commented Apr 3, 2018

@jfelipeara Yeah I just fix the file permissions or delete the files manually, e.g. using sudo.

These days I use php-fpm instead of mod_php though, so I don't have this issue (PHP runs under my user account instead of www-data).

@amanangira
Copy link

amanangira commented Apr 6, 2018

@davejamesmiller Well I ran through the same problem and stumbled upon this issue through google. Tried the cache:clear with sudo and it worked like a charm. Issue verified for Laravel 5.3.

@ohryan
Copy link

ohryan commented Jul 17, 2018

I just ran into this issue with 5.5.

I don't understand @taylorotwell's reasoning behind closing the issue. If a tool isn't doing what it says it does, then it really shouldn't return a success message. Seems pretty critical to me.

@DCzajkowski
Copy link
Contributor

In 5.5. ran into the same issue. Even sudo didn't help. From what I see, 5.6 has the same issue.

Even though flush() now returns a boolean, it is not handled appropriately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants