PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB_NestedSet » Bug #4762

triggerEvent passes node by value not by reference

Details

Request #4762triggerEvent passes node by value not by reference
Submitted2005-07-07 09:00 UTC
Fromstefan dot radulian at symbion dot at
Assigneddatenpunk
StatusBogus
PackageDB_NestedSet
PHP Version4.3.11
OSlinux
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