Re[4]: Re[2]: mixing of asign() and assign_by_ref() overwrites external vars
Dmitry Koteroff <[email protected]>
| Newsgroups | gmane.comp.php.smarty.devel |
|---|---|
| Message-ID | <[email protected]> |
>> (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.
--
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php