#24644 [Opn->Csd]: Fatal error because of private method
| From: | iliaa@php.net | Date: | Fri, 28 Nov 2003 14:30:00 +0000 |
| Subject: | #24644 [Opn->Csd]: Fatal error because of private method | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-51211@lists.php.net to get a copy of this message | ||
ID: 24644
Updated by: iliaa@php.net
Reported By: Bertrand dot Willm at laposte dot net
-Status: Open
+Status: Closed
Bug Type: XML related
Operating System: Windows XP
PHP Version: 5.0.0b2-dev
New Comment:
This bug has been fixed in CVS.
In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2003-08-19 09:53:32] Bertrand dot Willm at laposte dot net
On version PHP 5.0.0b2-dev there is no crash, but can't access to
private member.
The context is not the good one should be cbaseclass whereas it is
cextclass.
This is the error:
Fatal error: Call to private method cbaseclass::PrivateFunction() from
context 'cextclass' in c:\sitesweb\www\test.php5 on line 16
This is the code I used:
<?php
class CBaseClass {
var $name;
function Parse() {
$parser = xml_parser_create();
xml_set_object($parser, $this);
xml_set_element_handler($parser, array($this, 'StartElement'),
array($this, 'EndElement'));
$str = '<xml><node/></xml>';
xml_parse($parser, $str, true);
xml_parser_free($parser);
}
private function StartElement($parser, $name) {
echo $name, '<br>';
$this->PrivateFunction();
}
private function EndElement() {
}
private function PrivateFunction() {
}
}
class CExtClass extends CBaseClass {
}
$ExtObject = new CExtClass();
$ExtObject->Parse();
?>
------------------------------------------------------------------------
[2003-08-07 16:17:10] erik at erikcentral dot net
Correction.
The class works from the CLI but causes apache to segfault. Linux
phpV5.0.0b1
------------------------------------------------------------------------
[2003-08-07 16:07:54] erik at erikcentral dot net
<snip>
function CreateXMLParser() {
$this->parser = xml_parser_create("ISO-8859-1");
$new_ref = $this;
xml_set_object($this->parser, $new_ref);
xml_set_element_handler($this->parser,array($this,"myOpenElement"),array($this,"myCloseElement"));
xml_set_character_data_handler($this->parser,array($this,"myCharData"));
}
<snip>
works on Linux phpV5.0.0b1
Thanks helly@php.net
------------------------------------------------------------------------
[2003-07-29 09:12:47] sfox@php.net
Just a note to say I've now tested this with sane data and using
helly@php.net's array. It works fine if you call the base class
directly. I moved the $this->privateFunction() call to the
EndElement() function to check what's happening; when called via the
extended class, the entire thing works except that privateFunction()
throws its (expected) error.
Basically the xml parser handlers are bypassing the ppp checks.
Leaving this bug open as unsure whether this is intended behaviour.
------------------------------------------------------------------------
[2003-07-22 12:52:49] Bertrand dot Willm at laposte dot net
There is not difference with or without the &.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/24644
--
Edit this bug report at http://bugs.php.net/?id=24644&edit=1