Possible BUG: forward + renderDynamic

Hi everyone,

I have an action that is cached using COutputCache filter and that, sometimes, uses CController::forward to forward to another uncached action of the same controller (caching vary when it forwards, so it ends up never caching when it forwards).

It worked fine until I decided to modify both actions to use CController::renderDynamic to produce small parts of the output that vary dynamically.

The problem I found is that whenever the controller forwards to the target action, it seems not to keep the state of caching consistent. That way the output is produced with <###dynamic-X###> tags which are used internally to implement the dynamic caching mechanism.

If I run each action separately it works fine. If I remove dynamicRender from the target it also works, but it is not easy to treat it as a special case as lots of code is shared between many cached and uncached actions.

I took a look at the framework source code, and it seems that the caching stack should be adjusted once the forward method is called. Otherwise, the CController::processDynamicOutput method is delayed to COutputController which for some reason I could not figure out ends up not calling it and returning an unpatched the output.

The solution I gave seems to be a hack, but worked on my case. I overrode the CController::forward method to clear the caching stack before forwarding the action.




public function forward($route,$exit=true)

{

	$this->cachingStack->clear(); // hack to fix dynamicRender

	parent::forward($route,$exit);

}



I would like to know if this seems really a bug in the framework and if the fix I made is the most appropriate one.

Nevertheless, I am reporting in case someone else hits the same problem. I could not find others reporting so.

Cheers!