ZF-3456: Zend_View_Helper_Action Issue, duplicated view output
Description
Hey!.
A view named "view-chart.phtml" execute the action helper, <?= $this->action( "show-chart-main-panel", "diagnostic", "platform", array( "patient_id" => $this->intPatientId ) ); ?>, then the view of the second action ( "show-chart-main-panel" ) execute another action helper <?= $this->action( "show-record-image", "patient", "platform", array ( 'patient_id' => $this->intPatientId, 'patient_record_id' => $this->intPatientRecordId, 'field_id' => $this->intFieldId ) ); ?>, what's the issue ? the output of "show-record-image" appears twice on the "view-chart.phtml", any help ?
- view-chart.phtml:
View Chart:
<?= $this->action( "show-chart-main-panel", "diagnostic", "platform", array( "patient_id" => $this->intPatientId ) ); ?>- view-chart.phtml calls "show-chart-main-panel" action, this is the view of "show-chart-main-panel" action, show-chart-main-panel.phtml:
Show Cart Main Panel:
<?= $this->action( "show-record-image", "patient", "platform", array ( 'patient_id' => $this->intPatientId, 'patient_record_id' => $this->intPatientRecordId, 'field_id' => $this->intFieldId ) ); ?>- show-record-image.phtml:
Show Record
This is the final result:
View Chart:
Show Record
Show Cart Main Panel:
Show Record
"show-record-image" string is duplicated, any help ? Thx.
Comments
Posted by Matthew Weier O'Phinney (matthew) on 2008-06-16T09:04:27.000+0000
Assigning to Ralph; Ralph, please review and attempt a fix for the next mini release.
Posted by Paul Tomlin (ptomli) on 2008-07-17T03:44:19.000+0000
I can confirm the issue, and have worked out some vague understanding of the reason, and a solution.
It appears that nested actions prepend the previous response, or append the current one (depending on your standpoint)
If C actions B actions A
A results in A B results in ABA (should be BA) C results in ABACABA (should be CBA)
Blind digging in the code brought me to think this might have something to do with the fact that the request/response instances used in the helper are cloned in the constructor, and remain the same instances throughout the lifetime of the helper.
Exactly how this creates the situation above I have no idea, but creating new clones of the request/response objects (from the front controller) at the start of the 'action' method, and using them instead of the instance members produces the correct response.
I'd attach a patch, but I think someone who understands the issue would be better placed to produce something suitable.
Posted by Paul Tomlin (ptomli) on 2008-07-19T00:33:00.000+0000
A test and example fix.
Posted by Ralph Schindler (ralph) on 2008-07-25T15:11:57.000+0000
Fixed in 1.5.3 at r10440 Fixed in 1.6.0 at r10442