Bug #19752 [Ana]: connect() returns false even if it successfully connects

From: Date: Mon, 17 Dec 2012 13:02:54 +0000
Subject: Bug #19752 [Ana]: connect() returns false even if it successfully connects
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-9425@lists.php.net to get a copy of this message
Edit report at https://pear.php.net/bugs/bug.php?id=19752&edit=1 ID: 19752 Updated by: heino.gehlsen+php@gmail.com Reported By: lead2gold at gmail dot com Summary: connect() returns false even if it successfully connects Status: Analyzed Type: Bug Package: Net_NNTP Operating System: Centos 5.8 Package Version: 1.5.0RC2 PHP Version: 5.3.19 Roadmap Versions: New Comment: http://pear.php.net/bugs/bug.php?id=12057 (see comment by William Steinford @ 2009-11-04 16:28) Previous Comments: ------------------------------------------------------------------------ [2012-12-17 12:59:40] heino I haven't really been active in PEAR for years, but I don't think backward compatibility concerns have become less over time, so the returned false will just have to stay. I was never a fan of handling errors with PEAR_Error and would have preferred exceptions (and thus requiring PHP v5, but back then PEAR had to be v4 compatible. Today this way of error handling seems even more frustrating, but it's old code, and should in my opinion honestly be rewritten to present standards. I actually did write a exception based version a lot of years ago, but the package would have been required to be renamed Net_NNTP2 or something, and there was a new version of NNTP in the works, so I chose to not mess things up. And pretty much dropped PEAR altogether... Regarding the static call to PEAR::isError(), I suppose that it could be changed into $this->isError(), since this is apparently how PHP v5.x interprets it. The Net_NTTP v1.5.x requires PHP5 anyways due to use of PHP's streaming methods instead of Net_Socket, so from this version issues with PHP v4 can safely be ignored. The E_STRICT problem relates to ancient packages in PEAR - such as Net_NNTP and other mail related packages. Therefore you are always better off excluding E_STRICT when 'using' PEAR packages. http://pear.php.net/manual/en/core.pear.pear.seterrorhandling.php http://pear.php.net/manual/en/core.pear.pear.intro.php ------------------------------------------------------------------------ [2012-12-16 22:59:14] caronc One last comment... after experimenting with your sollution, i get the following now: Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /blah/bla on line XYZ Where line ''XYZ' is the PEAR::isError() call.. Now i know i can edit the php.ini file and disable E_STRICT... at least that's what every Google hit I search for tells me to do... but is that really the solution... to disable logging? ------------------------------------------------------------------------ [2012-12-16 22:22:32] caronc Thank you for the followup markup link; I can see this as being a workaround. I'm satisfied with that answer and 'suppose' a patch isn't necessary. I can also understand the requirement for backwards compatibility. Its just odd to call connect() and receive a false value and continue working as everything is okay. With respect to you first comment...are you implying that if i modify the patch to include a isPostingAllowed() public function you'll accept it and we can throw away our entire backwards compatibility discussion? How hypocritical of me to ask eh? ------------------------------------------------------------------------ [2012-12-16 21:50:26] heino http://svn.php.net/viewvc/pear/packages/Net_NNTP/trunk/docs/examples/phpdoc/con nect.php?revision=202843&view=markup ------------------------------------------------------------------------ [2012-12-16 21:48:36] heino -Status: Open +Status: Analyzed I agree it seems strange, but it does make sense however... As all protocol related methods connect() returns/'throws' an PEAR_Error object on failure, and one are supposed to check if such an object is returned before one continues. It's good old style PEAR - from before exceptions was accepted. I agree that the posting prohibited status could have been handled differently, but it was meant as a quick way of testing when connecting to post an article. At protocol level there should only be returned either posting allowed or prohibited on a successful connection attempt, and returning the state as boolean seemed natural - since a failure would return an PEAR_Error object. The addition af a returned false was added a long time ago (http://svn.php.net/viewvc/pear/packages/Net_NNTP/trunk/NNTP/Protocol/Client.php? r1=202233&r2=202234&), and changing it now would violate backward compatibility, so that's not an option. Regarding the proposed $_canPost variable, this might have been exactly what I had in mind back when I made the 'to do' comment ;-). There should however also be something like a isPostingAllowed() method or something... ------------------------------------------------------------------------ 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://pear.php.net/bugs/bug.php?id=19752 -- Edit this bug report at https://pear.php.net/bugs/bug.php?id=19752&edit=1

« previous php.pear.bugs (#9425) next »