ID:               24644
 User updated by:  Bertrand dot Willm at laposte dot net
 Reported By:      Bertrand dot Willm at laposte dot net
 Status:           Open
 Bug Type:         XML related
 Operating System: Windows XP
 PHP Version:      5.0.0b1 (beta1)
 New Comment:

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();
?>


Previous Comments:
------------------------------------------------------------------------

[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 [EMAIL PROTECTED]

------------------------------------------------------------------------

[2003-07-29 09:12:47] [EMAIL PROTECTED]

Just a note to say I've now tested this with sane data and using
[EMAIL PROTECTED]'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 &.

------------------------------------------------------------------------

[2003-07-16 02:54:13] [EMAIL PROTECTED]

Not good, but anyway please try without & for $this: 
array($this...)

------------------------------------------------------------------------

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

Reply via email to