Re[4]: [SMARTY-DEV] Re[2]: mixing of asign() and assign_by_ref() overwrites external vars

From: Date: Fri, 04 Jun 2004 20:19:48 +0000
Subject: Re[4]: [SMARTY-DEV] Re[2]: mixing of asign() and assign_by_ref() overwrites external vars
References: 1 2  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-2399@lists.php.net to get a copy of this message
>> (What is BC? "Before Christ"? Or, maybe, "Bachelor of Commerce"?) B> Hmmm. have you heard of the term Backwards Compatible? FWIW, "Bachelor B> of Commerce" is usually denoted B.Com. Sorry, my Russian-English dictionary thinks BC == B.Com. (-; >> Seems I know why are you so afraid to modify existing core. The >> reason is good and noble - you are afraid of new possible bugs. >> But everything has its measure. B> You are right about that -- conversely, I'm getting the idea B> that you are too ready to modify the core without considering B> how others might be using it :) Not "core", by "code" - typo. No matter. B> This breaks BC because it changes the way assign works. Wrong. Seems we do not understand each other again. B> In particular, what if someone is currently doing something like B> this: B> $a = "b"; B> $b =& $a; B> $smarty->assign('b', $b); B> So now in template {$b} == "b". However, if from a plugin: B> global $a; B> $a = "c"; B> With your patch, the in-template result is that now {$b} == "c" and B> this is *not* the currently expected result in Smarty. Wrong. In-template result will stay - "b". Try it if you do not believe. (-; Two examples (differ only by "&") with APPLIED patch: First: ------ {php} global $a; $a = "b"; $b =& $a; $this->assign('b', $b); {/php} 1: {$b}<br> {php} global $a; $a = "c"; {/php} 2: {$b}<br> Result: 1: b 2: b Second: ------- {php} global $a; $a = "b"; $b =& $a; $this->assign('b', &$b); {/php} 1: {$b}<br> {php} global $a; $a = "c"; {/php} 2: {$b}<br> Result: 1: b 2: c And, of course, this patch solves the problem in the first letter of this thread - re-assigning variable which was previously assigned by reference does not modify source: {php} $a = "a"; $this->assign_by_ref('a', $a); $this->assign('a', 'aaaaa'); echo $a; {/php} Result: a Without patch result is: aaaaa Maybe, you have meant something else? Please specify. (Words about deprecation of F(&$a) constructions are more realistic.) -- Best regards, Dmitry Koteroff.

« previous php.smarty.dev (#2399) next »