[RFC/PATCH]: push/popErrorHandling() in a class
| From: | Ian Eure | Date: | Tue, 06 Jan 2004 22:33:41 +0000 |
| Subject: | [RFC/PATCH]: push/popErrorHandling() in a class | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-24827@lists.php.net to get a copy of this message | ||
I recently ran into a problem with using push/popErrorHandling() inside a
class.
When calling PEAR::push/popErrorHandling() (that is, calling them statically)
inside an instance of any class which does not extend PEAR, I get this error
message:
'Fatal error: Call to undefined function: seterrorhandling() in
/usr/local/share/pear/PEAR.php on line 579'
This is the code in question:
if (isset($this)) {
$this->setErrorHandling($mode, $options);
} else {
PEAR::setErrorHandling($mode, $options);
}
According to the PHP documentation[1], "Thus, a class function may not use any
object variables (but it can use local and global variables), and it may no
use $this at all."
There have been several bug reports about this issue, 12622[2] in particular
states that this is the correct behavior of PHP.
I'm using PHP 4.1.2 and PEAR 1.2.1, on Debian stable. I've also reproduced the
problem with PHP 4.2.3 and PEAR 1.2.1 on Debian unstable.
I've attached my testcase, and a patch which fixes the problem for me. It
won't call $this->push/popErrorHandling() unless the class extends PEAR.
It is my belief that the above code is wrong, but pierre (paj) on #pear
disagreed. Comments?
[1]: http://www.php.net/manual/en/keyword.paamayim-nekudotayim.php
[2]: http://bugs.php.net/bug.php?id=12622
Attachment: [text/x-diff] errorHandling.patch
Attachment: [text/x-c++src] pushErrorHandling Testcase.php
Attachment: [text/x-diff] errorHandling.patch
Attachment: [text/x-c++src] pushErrorHandling Testcase.php