using cache in widget renderContent method

when calling:

if (CBaseController::beginCache(‘newcattree’)) {



in widget’s renderContent method, I got:

Fatal error: Call to a member function getUniqueId() on a non-object in C:\Users\Project Manager\workspace\f\yiiext\framework\web\widgets\COutputCache.php on line 265

What’s wrong?



report it as a bug please

To solve your problem do something like this:



        	//your code here

        	echo $content=ob_get_clean();


I think this solution with flushing the buffer ISN’T the good one. If I start flushing the buffer, I can’t modify header (e.g. cookies, redirection, etc)

yes you can

the buff will only be enabled for a little piece of code and wont interfer in actions like the ones you pointed out

I just checked COutputCache widget and it does exactly the same as i mentioned

My fault.

Please refer to the guide on how to use fragment caching. Basically, you should use $this->controller->beginCache() instead of CBaseController::beginCache(). The latter calls the method in a static way, which is incorrect.