Fwd: [PEAR-BUG] Bug #7692 [Fbk->Csd]: readLine exits silently on error
| From: | Chuck Hagenbuch | Date: | Fri, 02 Jun 2006 18:49:30 +0000 |
| Subject: | Fwd: [PEAR-BUG] Bug #7692 [Fbk->Csd]: readLine exits silently on error | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-42751@lists.php.net to get a copy of this message | ||
Hi folks-
I'd like some feedback from other developers on what "the right thing" to do in this case is. If I was starting from scratch with Net_Socket, I'd make different choices about error handling and silencing. But it's been surpressing trivial warnings forever now, so simply stopping doesn't seem like nice behavior to me.
(I know, warnings shouldn't be on in production, blah blah blah. And I agree. But it's been the behavior to silence them since the very first versions of the package, so that's the issue as I see it.)
On the other hand, the patch I posted in this bug report doesn't sit well with me either. And I agree with the reporter that silencing a fatal execution_time error isn't nice either.
Advice, flames, thoughts?
----- Forwarded message from pear-qa@lists.php.net -----
Date: 2 Jun 2006 09:14:03 -0000
From: jason dot e dot stewart at gmail dot com <pear-qa@lists.php.net>
Subject: [PEAR-BUG] Bug #7692 [Fbk->Csd]: readLine exits silently on error
To: stig@php.net, chuck@horde.orgEdit report at http://pear.php.net/bugs/bug.php?id=7692&edit=1
ID: 7692User updated by: jason dot e dot stewart at gmail dot com
Reported By: jason dot e dot stewart at gmail dot com -Status: Feedback +Status: Closed Id: 7692 Type: Bug Package: Net_SocketOperating System: Windows NT Package Version: 1.0.6
PHP Version: 5.0.2New Comment: yup, that does the trick for me. without the @fgets(), the error gets propagated. Thanks. Previous Comments: ------------------------------------------------------------------------ [2006-05-28 21:44:56] chagenbu at php dot net Here you are: Index: Socket.php =================================================================== RCS file: /repository/pear/Net_Socket/Socket.php,v retrieving revision 1.25 diff -u -r1.25 Socket.php
--- Socket.php 15 Nov 2005 03:48:06 -0000 1.25+++ Socket.php 29 May 2006 01:44:26 -0000 @@ -441,14 +441,17 @@
return $this->raiseError('not connected');
}
+ ob_start();
$line = '';
$timeout = time() + $this->timeout;
while (!feof($this->fp) && (!$this->timeout || time() <
$timeout)) {
- $line .= @fgets($this->fp, $this->lineLength);
+ $line .= fgets($this->fp, $this->lineLength);
if (substr($line, -1) == "\n") {
+ ob_end_clean();
return rtrim($line, "\r\n");
}
}
+ ob_end_clean();
return $line;
}
------------------------------------------------------------------------
[2006-05-27 13:02:31] jason dot e dot stewart at gmail dot com
yes, I still have my application set up on the test server. It would be
easy to test. Send my a patch and I'll try it out.
------------------------------------------------------------------------
[2006-05-26 14:18:00] chagenbu at php dot net
Okay, I did misunderstand you. I have very mixed feelings about this.
On the one hand, silencing a fatal error is never a good thing -
completely with you on that. However there are probably a ton of
applications and packages out there that expect Net_Socket not to
generate warnings, thus potentially breaking header() calls, or
generally mucking things up.
I'm not sure what the answer is here. I wonder what would happen if we
called ob_start() before the fgets/fread calls in question, assigned
the data instead of returning it, then ob_end_clean(), finally return
the result. That'd effectively silence warnings still; the question is
if it'd silence the fatal error. Would you be willing to test this?
------------------------------------------------------------------------
[2006-05-23 01:24:05] jason dot e dot stewart at gmail dot com
Maybe I was unclear.
When the socket read exceeds the max_execution_time setting it causes a
FATAL ERROR - this error is discarded because of @fgets():
PHP Fatal Error: maximum execution time of 30 secs exceeded in
c:\Program Files\php5\PEAR\Net\Socket.php on line 448
My script exits completely because of this error - and nothing I do can
trap it - so I am clueless what is happening.
I was only able to get the above text by removing the '@' operator.
Discarding warnings is one thing - but discarding errors is a righteous
pain in the a**...
------------------------------------------------------------------------
[2006-05-22 14:05:01] chagenbu at php dot net
Well, not everyone is using a custom error handler that would catch
warnings. For some scripts, if a warning was generated (say a request
times out), they might just want to get back a return false and
redirect somewhere else - but oops, headers have already been sent.
Since fgets() will only ever generate a warning, not a fatal error (by
itself), we silence it.
------------------------------------------------------------------------
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=7692-- Edit this bug report at http://pear.php.net/bugs/bug.php?id=7692&edit=1 ----- End forwarded message ----- -chuck -- "we are plastered to the windshield of the bus that is time." - Chris