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

Active compiled style files are being pruned away #20

Merged
merged 3 commits into from
Nov 24, 2012
Merged

Conversation

thom4parisot
Copy link
Owner

I checked my web site this morning to find out that the CSS was missing. Clearing my caches and forcing a recompile of my LESS file resolved the problem. I can confirm from my access logs that the WP-LESS garbage collector was active when the file went missing.

I did see the following message in my error logs from that time period. But more importantly, I need to figure out why GarbageCollector thinks it can remove my active files! My suspicion is that there is an undesirable interaction with my fastcgi caching.

error.log.1:2012/11/13 15:51:23 [error] 29972#0: *495312 FastCGI sent in stderr: 
"PHP message: PHP Warning:  unlink(/home/wordpress/cvxr/assets/wp-less/cvxrb/..) 
[<a href='function.unlink'>function.unlink</a>]: 
Is a directory in /home/wordpress/cvxr/wp-content/plugins/wp-less/lib/Garbagecollector.class.php on line 67

@mcg1969
Copy link
Author

mcg1969 commented Nov 14, 2012

Yes, I'm fairly certain that caching must have something to do with it. As far as I can tell, the garbage collector is pruning all files older than a certain age, under the assumption that they will be regenerated automatically. But as long as the pages are being served from cache, there is no opportunity for regeneration. I would suggest modifying the garbage collector so that the most recent file is not pruned away.

@thom4parisot
Copy link
Owner

You are right: the collector is designed by thinking active stylesheets are going to be regenerated.

I may look to generate them during garbage collection. Just need to check if the theme is available or safely loadable from cron.

Meanwhile, I can add a setTtl method to alter the lifetime of a compiled stylesheet to avoid this problem.
Or even an option to disable garbage collection.

Thanks for reporting!

@ghost ghost assigned thom4parisot Nov 15, 2012
thom4parisot pushed a commit that referenced this pull request Nov 24, 2012
Active compiled style files are being pruned away
@thom4parisot thom4parisot merged commit 2a30f95 into master Nov 24, 2012
@fabrizim
Copy link
Collaborator

I am still seeing this issue (1.5.3). I did not have a filter for the TTL though. However, I think that the compilation strategies should include a check for the existence of the cached file. If it does not exist, that should trigger a compile. I will see if I can accomplish this with hooks. I will leave another comment here if I find a good solution.

@thom4parisot thom4parisot deleted the bug-20 branch July 29, 2013 15:26
@thom4parisot
Copy link
Owner

@fabrizim actually it is very hard to do that without doing that "runtime". The cleaning is done in the background during a WP-Cron so most of the functions.php are not active if I remember well.

Initially I did not want to introduce too much complexity with that feature and I recon it's more tricky than expected.

Several hints:

  • having a better algorithm cleaning the files, less aggressive/error prompt
  • tracking theme compilations and use this as a reference to prune the compiled files

I have very few time to work on it so if you have quick and effective bit of code to PR, you're welcome :-)

@fabrizim
Copy link
Collaborator

I added a quick pull request (#40). Let me know if you think it might work, or if I am missing something.

@thom4parisot
Copy link
Owner

Yup I've just seen it. It advertise the origin of the problem: the database value is out of sync with the file system.
Which is great!

I wonder how to deal with any cache system (like W3 TotalCache or Hyper Cache) as they rely on content and not on assets…

@sebastianschmid
Copy link
Collaborator

I don't think cache systems are an issue... 1) many of them have the (default) option to deactivate caching while logged in, and 2) the first thing to try, if you're working on the site and you're having obvious "caching issues", would be to clear / turn off the cache ...

@fabrizim
Copy link
Collaborator

I agree with @sebastianschmid - from what I know of w3 total cache, I am pretty sure it should work just like regular stylesheets: stylesheets are cached and changes won't be reflected until the cache is cleared. At that point, the css is generated as usual and then cached per their own caching algorithm. I'm pretty sure this PR would still work during that process.

@fabrizim
Copy link
Collaborator

fabrizim commented Aug 5, 2013

@oncletom - I hate to be a nuisance, and I know you are busy, but I have tested the referenced pull request and it has been working for me. Any chance you could pull it into master? I have several sites using this that are sourced from git and it would be great to resolve this issue (which has become fairly prominent on some sites). Thanks.

@thom4parisot
Copy link
Owner

@fabrizim you're totally right ;-) Thanks for reminding me!

@fabrizim
Copy link
Collaborator

fabrizim commented Aug 9, 2013

@oncletom Thanks!

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

Successfully merging this pull request may close these issues.

4 participants