silverstripe/silverstripe-framework — pull request #3393 by halkyon (2014-08-16 01:06:18+00:00)
Title: NEW Provide a consistent way of triggering flush using an interface

Anything that implements Flushable should implement a flush() function
which is used to clean caches, or do actions that need to run in the
times where ?flush=1 is called on a request.

This fix came out of an issue where Requirements combined files were not
being cleaned up after dev/build?flush=1, due to the fact that flush
would only occur when you called it while on a page that used those
combined files, but not in any other contexts. This will now call flush
on any implementors of Flushable regardless of the context of where
flush was called.

I've simply set a flush variable in some cases like `Image` and `RestfulServer`
so it works the same as before for those. Currently those classes don't have
any way of clearing all caches yet in one go (e.g. like SSViewer::flush_template_cache()), but if you
think we should do that, I'll get onto it :) `RestfulServer` is especially annoying
in that it doesn't use `SS_Cache` for it's caching.

In the case of `SSViewer::__construct()` doing a `Security::permissionFailure()`
if flush was called, but you don't have permission, I don't think that's needed
anymore. I tested putting the site in test mode and trying to flush, it still asks
to login first.

Wasn't sure whether we should do this for a 3.1 or 3.2 release, let me know what
you think.