[Tickets #4062] Re: Kolab.php compatibility with php5

bugs@bugs.horde.org bugs at bugs.horde.org
Wed Nov 15 03:56:22 PST 2006


DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.

Ticket URL: http://bugs.horde.org/ticket/?id=4062
-----------------------------------------------------------------------
 Ticket             | 4062
 Updated By         | wrobel at gentoo.org
 Summary            | Kolab.php compatibility with php5
 Queue              | Kolab
 Type               | Bug
 State              | Feedback
 Priority           | 2. Medium
 Owners             | 
-----------------------------------------------------------------------


wrobel at gentoo.org (2006-11-15 03:56) wrote:

> One questions though, shouldn't the document object be passed by 
> reference to the dom constructors?

As mentioned I forwarded the question:

One of the Horde programmers wanted to know if it would be better to
pass the parent document as a reference when creating Nodes, Elements
or Attributes (http://bugs.horde.org/ticket/?id=4062). I am not quite
certain if there is a specific reason against it so I thought I just
try to ask you for your opinion.

Answer from Alexandre Alapetite:

I am not really sure to understand your question...

1) When creating a new element, there is already a (indirect) reference to
the parent document, as you can see on your line 155
(the "$this" reference)
http://cvs.horde.org/co.php?r=1.5&f=framework%2FDOM%2FDOM.php

    function create_element($name) 
    {
        return new Horde_DOM_Element($this->node->createElement($name),
$this);
    }

On this line 155, the "$this" is referring to a Horde_DOM_Document which
is the parent document, which inherits from
Horde_DOM_Node which contains a reference "$this->node" or to the real
PHP5 XML DOMDocument.


2) If you mean passing the parent document "by reference", in opposition
to "by value", this is not a good idea as objects
variables in PHP5 are already references. When making an assignment, there
is no copy of the object. So passing the parent "by
reference" would make a pointer of pointer quite strange, error prone, and
I do not see the interest.


3) In my library since version 1.8 I think, I have an additional attribute
"myOwnerDocument" for php4DOMNode objects (which you
call "Horde_DOM_Node") which is a direct reference to the parent document
and provides speed improvement
http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/

See line 196 of
http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/domxml-php4-to-php5.php.txt
You may want to update your code accordingly.





More information about the bugs mailing list