ProcessWire-AIOM-All-In-One-Minify icon indicating copy to clipboard operation
ProcessWire-AIOM-All-In-One-Minify copied to clipboard

CacheFile for Pages - PW3 issue, and ClearCacheFromBackend problem

Open gingebaker opened this issue 9 years ago • 0 comments

Hi I got two problems that all have to do with the Processwire Template Cache when using AIOM.

1) First of the ClearCacheFromBackend issue: Following initial situation:

  • I have the template cache enabled and pages are in the cache
  • I have AIOM Files in the cache
  • Now Goto AIOM Config Screen and click "Empty Cache" (/module/edit?name=AllInOneMinify).
  • Then Goto to the Frontend (with a non logged in browser) on a page where TemplateCache should be active.
  • The CSS and JS Files are not there anymore and breaks the layout.

In the AllInOneMinify::ClearCacheFromBackend Funtion there is no direct removal of the cache files. On cached Version in Frontend AIOM never reaches the point where the CacheFiles would be deleted, wich is here for JS and here for CSS:

If i am adding this code in ClearCacheFromBackend after self::_clearCache(true); here

$pageRender = wire('modules')->PageRender;
if($pageRender) {
   CacheFile::removeAll(wire('config')->paths->cache.PageRender::cacheDirName."/");
}

this issue is removed. Can anyone confirm this?

2) The second Problem has a direct relation to this, so I post it here. When using AIOM in PW3 I think the class_exists function used for checking if PageRender exists never returns true.

This has todo with Namespaces in PW3 I guess (see php.net comment). Also the compiled FileCompiler Version does not add anything to the class_exists call. However, I am wondering it this if statement with class_exists is needed anyway. Beacause PageRender cannot be uninstalled, it should always be there. Perhaps I´m missing something here? Another way of checking without class_exists would be the way I do it in the Example above.

I hope that someone can confirm this issues and write back. I had two sites broken in the last week. I don´t know exactly what happened that AIOM FileCache got cleared in the backend, but with this simple solution it should not happen anymore...

I can make a pull request if this helps... thanks

gingebaker avatar Dec 06 '16 11:12 gingebaker