|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24622 Net_SmartIRC: $x=new x; if(!$x) ... fails on PHP 4.1.2
Submitted: 2003-07-12 13:06 UTC Modified: 2003-07-15 17:05 UTC
From: phpbugsspam at netebb dot com Assigned: meebey (profile)
Status: Closed Package: PEAR related
PHP Version: Irrelevant OS: Any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: phpbugsspam at netebb dot com
New email:
PHP Version: OS:


 [2003-07-12 13:06 UTC] phpbugsspam at netebb dot com
With PHP 4.1.2, this patch is needed to operate correctly:

$ diff -uw SmartIRC.php.bak SmartIRC.php
--- SmartIRC.php.bak    Sat Jul 12 10:09:45 2003
+++ SmartIRC.php        Sat Jul 12 11:02:39 2003
@@ -1280,7 +1280,7 @@
         $id = $this->_actionhandlerid++;
         $newactionhandler = &new Net_SmartIRC_actionhandler();
-        if (!$newactionhandler) {
+        if ($newactionhandler === false) {
             return false;
@@ -1386,7 +1386,7 @@
         $id = $this->_timehandlerid++;
         $newtimehandler = &new Net_SmartIRC_timehandler();
-        if (!$newtimehandler) {
+        if ($newtimehandler === false) {
             return false;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-15 10:31 UTC]
Why do you think it needs this patch to work correctly,
wat happens without the patch?

 [2003-07-15 11:16 UTC] phpbugspam at netebb dot com
I don't "think" it needs a patch.  It does need it.

Without it, !$newactionhandler evals to true and the function returns false, which is not correct.

It appears that applying negation '!' to a newly created object, returns false, even if the object is a valid object.

Of course, this is with PHP 4.1.2 that comes with Debian Woody, your version may work different.  Do ask *me* why!

Now it's my turn to ask why.  Why *not* apply it?  It's a simple enough patch, and certainly wont break anything.

 [2003-07-15 12:32 UTC]
That === false check is nonsense, imho.
=== false checks if the first operand is false, of the type boolean - which is impossible unless you set $this to false in the constructor, which is a dirty hack and won't happen if you do sane coding. So, === false is bogus.
An object just evaluates to false if it has no member variables... maybe that is what happens. Maybe a default value in the classes will "fix" this...

(Note: IMO, the check if object creation was "successful" isn't neccessary at all, because there's no reason for it to fail except for "class not found", and that's a fatal one.)

 [2003-07-15 17:05 UTC]
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
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

I removed the checks...

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Nov 28 08:03:16 2021 UTC