Zend Framework

Zend_View_Helper_Action Issue, duplicated view output

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.5.2
  • Fix Version/s: 1.5.3
  • Component/s: Zend_View
  • Labels:
    None
  • Fix Version Priority:
    Must Have

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:

<div>
<h3>View Chart:</h3>

<?= $this->action( "show-chart-main-panel", "diagnostic", "platform", array( "patient_id" => $this->intPatientId ) ); ?>
</div>

  • view-chart.phtml calls "show-chart-main-panel" action, this is the view of "show-chart-main-panel" action, show-chart-main-panel.phtml:

<div>
<h3>Show Cart Main Panel:</h3>

<?= $this->action( "show-record-image", "patient", "platform", array ( 'patient_id' => $this->intPatientId, 'patient_record_id' => $this->intPatientRecordId, 'field_id' => $this->intFieldId ) ); ?>
</div>

  • show-record-image.phtml:

<div>
<h3>Show Record</h3>
</div>

This is the final result:

<div>
<h3>View Chart:</h3>
<div>
<h3>Show Record</h3>
</div>
<div>
<h3>Show Cart Main Panel:</h3>
<div>
<h3>Show Record</h3>
</div>
</div>
</div>

"show-record-image" string is duplicated, any help ? Thx.

  1. ZF-3456-fix.patch
    19/Jul/08 12:33 AM
    2 kB
    Paul Tomlin
  2. ZF-3456-test.patch
    19/Jul/08 12:32 AM
    2 kB
    Paul Tomlin

Issue Links

Activity

Hide
Matthew Weier O'Phinney added a comment -

Assigning to Ralph; Ralph, please review and attempt a fix for the next mini release.

Show
Matthew Weier O'Phinney added a comment - Assigning to Ralph; Ralph, please review and attempt a fix for the next mini release.
Hide
Paul Tomlin added a comment -

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.

Show
Paul Tomlin added a comment - 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.
Hide
Paul Tomlin added a comment -

A test and example fix.

Show
Paul Tomlin added a comment - A test and example fix.
Hide
Ralph Schindler added a comment -

Fixed in 1.5.3 at r10440
Fixed in 1.6.0 at r10442

Show
Ralph Schindler added a comment - Fixed in 1.5.3 at r10440 Fixed in 1.6.0 at r10442

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: