Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.2

Request #14433 gets(), optional size parameter
Submitted: 2008-08-01 08:51 UTC
From: heino Assigned: chagenbu
Status: Closed Package: Net_Socket (version 1.0.9)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    

 [2008-08-01 08:51 UTC] heino (Heino H. Gehlsen)
Description: ------------ According to the PHP manual ( the size parameter in fgets() has been optional since PHP v4.2, yet in Net_Socket::gets() it is not. Unfortunately it is not possible to do a simple hack like $socket->gets(null), since PHP does not allow using null in the size parameter (tested on PHP v4.4 and v5.2). There should be no trouble making an enhancement in this case, since Net_Socket v1.0.9 depends on PEAR v1.4.0b1, which again depends on PHPv4.2. It could/should however be noted in the documentation that in good old PHP v4.2 the lack of the size parameter equals a size of 1024. Existing code wouldn’t be affected, and since even PHP v4.4 was discontinued 31/12/2007 nobody should run into trouble... --- Socket.php.orig 2008-08-01 10:46:18.000000000 +0200 +++ Socket.php 2008-08-01 10:46:38.000000000 +0200 @@ -280,10 +280,14 @@ * @return $size bytes of data from the socket, or a PEAR_Error if * not connected. */ - function gets($size) + function gets($size = null) { if (!is_resource($this->fp)) { return $this->raiseError('not connected'); } + + if (is_null($size)) { + return @fgets($this->fp); + } return @fgets($this->fp, $size); }


 [2008-12-01 17:29 UTC] chagenbu (Chuck Hagenbuch)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on by the end of next Sunday (CET). If this was a problem with the website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.