Home » Database » DB_NestedSet » Bug #4762
triggerEvent passes node by value not by reference
Details
| Request #4762 | triggerEvent passes node by value not by reference |
|---|---|
| Submitted | 2005-07-07 09:00 UTC |
| From | stefan dot radulian at symbion dot at |
| Assigned | datenpunk |
| Status | Bogus |
| Package | DB_NestedSet |
| PHP Version | 4.3.11 |
| OS | linux |
| Roadmaps | (Not assigned) |
Comments
[2005-07-07 09:00 UTC] stefan dot radulian at symbion dot at
Description:
------------
this is a suggestion.
file: /PEAR/DB/NestedSet.php
line: 715-717
i think it's better to pass the node by reference as this allows to change the nodeset in a listener after the node is loaded.
i needed this to add some more properties to a node after loading it.
HTH
stefan.
Reproduce code:
---------------
foreach (array_keys($nodeSet) as $key) {
$this->triggerEvent('nodeLoad', &$nodeSet[$key]);
}
[2005-10-25 23:21 UTC] datenpunk at php dot net
It is passed by reference:
function triggerEvent($event, & $node, $eparams = false)
Calltime pass by reference (the way you did it) throws a notice on current php versions IIRC.
Look at http://www.sitepoint.com/article/object-oriented-php/7 for more information on call time pass by reference.
--
Daniel Khan