Development

#3391 (Rendering partials multiple times, messing up parameters)

You must first sign up to be able to contribute.

Ticket #3391 (closed defect: fixed)

Opened 7 months ago

Last modified 7 months ago

Rendering partials multiple times, messing up parameters

Reported by: PeterMuusers Assigned to: fabien
Priority: minor Milestone: 1.1.0 RC1
Component: view Version: 1.1.0 BETA3
Keywords: view parameters partial extract Cc:
Qualification: Unreviewed

Description

It's hard to explain in words what the issue is exactly, so i have attached a module directory which reproduces the issue.

Basically i have an action that defines an array with objects (for example with id's 1,2,3 and 4) for use in the template.

The template calls a partial multiple times and supplies the array with objects as a parameter.

That partial iterates through the objects and calls another partial, with one of the objects in the array as a parameter.

The first time that we iterate through the objects, all is fine... i get objects 1,2,3 and 4. However, after calling the partial again, and again... the array contains objects: 4,2,3 and 4

In the partials themselves, nothing really happens that could alter the array with the objects.

I was able to fix this for my project, by changing the renderFile() in sfPHPView. instead of using: extract($this->attributeHolder->toArray(), EXTR_REFS); i use extract($this->attributeHolder->toArray(), EXTR_OVERWRITE);

And the array with objects retains the objects with id 1,2,3 and 4

I'm not sure if this is the right way to fix this, maybe someone with better knowledge about the core files and the View classes can look into this.

This issue only occurred to me when calling partials from partials multiple times.

Attachments

testcase.zip (3.5 kB) - added by PeterMuusers on 04/23/08 11:44:21.
Module directory with a simplified example that reproduces the issue

Change History

04/23/08 11:44:21 changed by PeterMuusers

  • attachment testcase.zip added.

Module directory with a simplified example that reproduces the issue

04/28/08 09:37:01 changed by fabien

  • milestone set to 1.1.0 RC1.

05/04/08 14:25:58 changed by fabien

  • status changed from new to closed.
  • resolution set to fixed.

in r8768