cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

the variables in partials globalize after upgrade to 3.0.1 (volt)

Open odat opened this issue 10 years ago • 12 comments

Hello, the variables in partials globalize, how i can set some of variable on some partials and don't defined on another one on the same view

for example in controller i pass id on view by $this->view->id = '1' ;

in the view template :

{{ id }}   {# now the id is 1 #} 

{{ partial("some/partial",['id':'2','another':3]) }}

{{ id }}   {# now the id is 2 #} 

{{ another}}   {# and i can use another now, it's defined!! #} 

when i defined the some partial with another id , the id is overwritten on the old one on the page

Thanks,

odat avatar Nov 01 '16 06:11 odat

You have php 7 ? I think this is why it's happening, not because of 3.0.1

Jurigag avatar Nov 01 '16 07:11 Jurigag

Yes php 7, but can i get some way to fix this issue

odat avatar Nov 01 '16 12:11 odat

Then do PR if you have any solution or it's just workaround ?

Jurigag avatar Nov 03 '16 06:11 Jurigag

Has this issue been fixed? Workaround maybe?

seliver avatar Feb 01 '17 13:02 seliver

This is due to zephir incompatibilities with php7: https://forum.phalconphp.com/discussion/14497/view-variables-are-surprising-bug-or-feature @phalcon Is there a workaround for this?

seliver avatar Feb 01 '17 13:02 seliver

I don't think there is right now @andresgutierrez any plans to fix this?

Jurigag avatar Feb 01 '17 13:02 Jurigag

I can confirm the bug occurring on php7 alone. Especially, when I call getRender(). I'll post my code, if it helps fixing the issue

//User has firstName, lastName, email, and more...
$content = $this->view->getRender("mail", "newPass",
    [
        "user" => $user->firstName . ' ' . $user->lastName,
        "base_url" => 'https://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']
    ]
);
// After this part, User has only firstName and lastName.

alivex avatar Apr 06 '17 12:04 alivex

I found a new super behavior

    {{ robot.getPart() }} //part object #....
    {{ partial("_partials/show-part", ['part':robot.getPart()]) }} //render fine
    {{ robot.getPart() }} //robot is null!!!!

pain solution

    {% set part = robot.getPart() %} //part object #....
    {{ partial("_partials/show-part", ['part':part]) }} //render fine
    {{ robot.getPart() }} //robot is fine

Enviroment: PHP 7.0.21, Phalcon 3.2.1, Zephir 0.9.9, Apache 2, MariaDB 10, Windows 7

emiliodeg avatar Jul 31 '17 19:07 emiliodeg

Hi,

I have this issue too and it's a real pain to work with on bigger scale projects ! Please, if you can, fix this as soon as possible

Many thanks in advance

Environement : Debian 9, Nginx 1.12, PHP 7.2.2, Phalcon 3.3.1

feloot avatar Feb 06 '18 20:02 feloot

This robot shouldn't close issues tagged as bugs

emiliodeg avatar Aug 07 '18 17:08 emiliodeg

I agree @sergeyklay

Jurigag avatar Aug 07 '18 17:08 Jurigag

I hope we managed to sort out with this issue finally here https://github.com/phalcon/cphalcon/pull/13606. All necessary changes are already in the appropriate branch. We will try to release the next version in the coming days. Thank you for your patience, the report, and for helping us make Phalcon better.

sergeyklay avatar Nov 20 '18 22:11 sergeyklay