Fix serialization of request, helpers and viewVars when they contain a closure

`CacheHelper::_writeFile()` fails if you have a closure in any of `$this->request`, `$this->_View->helpers` or `$this->_View->viewVars`. An exception is thrown by the call to `serialize()`.

I think this issue would most commonly occur when using a callback custom detector in `CakeRequest`.
That's bad imo. [Here's](https://github.com/cakephp/cakephp/commit/9b94133f0d1cba534e78aba96f5546adc33e5889) where that change was done. But the issue number probably refers to ticket on lighthouseapp which we used earlier, so don't know what's the reason for doing this.