Use of assign_by_ref() is not clear as to what is required
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mahara |
Fix Released
|
Low
|
Cecilia Vela Gurovic |
Bug Description
In Mahara we have a bunch of $smarty-
It was originally added to smarty/dwoo due to the following
"The assign_by_ref() original intention in Smarty 2 was to work around the object-by-copy behavior of PHP4."
"The _by_ref methods have been introduced in Smarty2 mainly to be able to pass objects to the templates in PHP4. In PHP5 these are passed alway as a reference."
But it doesn't look like we use them in a true reference sort of way
What I mean is, this example shows referenced vs not referenced 'title' variable:
$smarty = smarty();
$title = 'cats';
$smarty-
$smarty-
$title = 'dogs';
$smarty-
In the template it will display 'cat' as title and 'dogs' as titleref rather than 'cat'.
We don't support PHP4 and so should clean up the code and make the assign_by_ref() calls simply assign() where appropriate to make the code clear as to what we are wanting.
Changed in mahara: | |
milestone: | none → 16.10.0 |
Changed in mahara: | |
assignee: | nobody → Cecilia Vela Gurovic (ceciliavg) |
Changed in mahara: | |
status: | New → In Progress |
Changed in mahara: | |
status: | In Progress → Fix Committed |
Changed in mahara: | |
status: | Fix Committed → Fix Released |
When I change the lib/web.php line
$smarty- >assign_ by_ref( 'JAVASCRIPT' , $javascript_array);
to
$smarty- >assign( 'JAVASCRIPT' , $javascript_array);
The resulting dataroot/ dwoo/compile/ .../htdocs/ mahara- testing/ mahara/ htdocs/ theme/raw/ templates/ header/ head.tpl. d17.php looks to be the same for either option