PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » XML » XML_Parser » Bug #3555

References to $this are given to the outside world during construction

Details

Submitted2005-02-22 16:56 UTC
Fromtorben-spam-phpbugs at nehmer dot net
StatusBogus
PackageXML_Parser
PHP Version4.3.10
OSLinux
Roadmaps(Not assigned)

Comments

[2005-02-22 16:56 UTC] torben-spam-phpbugs at nehmer dot net

Description:
------------
When initialized with something like this

parent::XML_Parser(null, 'func', 'UTF-8');

... the constructor calls setMode, which in turn passes a reference to $this to Expat, which fails really big in the respect that the reference gets lost when the object is copied after creating it. (You usually do "$p = new Parser", not "$p =& new Parser".) This is a known limitation of PHP, you should either use a static factory method or find some other way to avoid this.

Solution: Don't pass the this reference out during construction, do this immediately before parsing.

Reproduce code:
---------------
Check the following CVS page, class midcom_services_indexer_XMLComm_ResponseReader.

http://midcom.tigris.org/source/browse/midcom/fs-midcom/lib/midcom/services/indexer/XMLCommClient.php?rev=HEAD&content-type=text/vnd.viewcvs-markup

I need to call setMode('func'); again in my parse function to make it work.

[2005-02-25 17:18 UTC] torben-spam-phpbugs at nehmer dot net

Ah ok. Good hint. Somehow I was in the impression that my Pear installation on my devel server here was up to date. It was 1.0.1, 1.2.4 source looks good, will test it later.

Thanks and sorry for the hazzle.