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

Bug #16657 Net_NNTP problems with PHP 5.2.11
Submitted: 2009-09-29 17:03 UTC
From: ddfly Assigned: ddfly
Status: Bogus Package: Net_NNTP (version 1.4.0)
PHP Version: 5.2.11 OS: FreeBSD & Windows
Roadmaps: (Not assigned)    
Subscription  


 [2009-09-29 17:03 UTC] ddfly (Jim Jones)
Description: ------------ While a script used to work with PHP 5.2.10 and earlier versions on both FreeBSD and Windows, now no longer works with the latest version of PHP 5.2.11: Error Message: Data stream not terminated with period Tested on default PHP installations confirms that a change between 5.2.10 and 5.2.11 broke something with Net_NNTP. Haven't tested on PHP 5.3.0 yet. Test script: --------------- require_once('Net/NNTP/Client.php'); $NNTP = new Net_NNTP_Client(); $NNTP->connect('news.example.com', false, 119); $NNTP->authenticate('username', 'password'); $newsgroups = $NNTP->getGroups(); if (PEAR::isError($newsgroups)) { echo 'Fetching list of groups failed: ' . $newsgroups->getMessage(); exit; } var_dump($newsgroups); Expected result: ---------------- Array dump of $newsgroups Actual result: -------------- Fetching list of groups failed: Data stream not terminated with period

Comments

 [2009-09-29 23:22 UTC] heino (Heino H. Gehlsen)
-Status: Open +Status: Feedback
Not enough information was provided for us to be able to handle this bug. Please re-read the instructions at http://bugs.php.net/how-to-report.php If you can provide more information, feel free to add it to this bug and change the status back to "Open". Thank you for your interest in PEAR. Hi Jim, I simply can't help you based on the provided information! Aparently the servers termination of its response is not registered... You could use the PEAR logger class to make dump of the conversation between server and client. An example on how to use it can be found in the example application (http://svn.php.net/viewvc/pear/packages/Net_NNTP/trunk/docs/examples/demo/common.inc.php?revision=261287&view=markup) provided with the Net_NNTP class.
 [2009-09-30 01:08 UTC] ddfly (Jim Jones)
The generated log isn't telling me anything significant, it seems the script is randomly stopping after receiving a few thousand newsgroups: FIRST LOG ======= Sep 29 19:03:01 Net_NNTP [debug] S: 281 Welcome Sep 29 19:03:01 Net_NNTP [debug] C: LIST ACTIVE Sep 29 19:03:01 Net_NNTP [debug] S: 215 NewsGroups Follow Sep 29 19:03:01 Net_NNTP [debug] T: .complete_cd 0000000037 0000000010 y Sep 29 19:03:01 Net_NNTP [debug] T: .usa 0000000122 0000000017 y Sep 29 19:03:01 Net_NNTP [debug] T: 0 0000000069 0000000025 y [...snip...] Sep 29 19:03:02 Net_NNTP [debug] T: agora.scienza.scienza 0000000003 0000000002 y Sep 29 19:03:02 Net_NNTP [debug] T: agora.scienza.vatinno 0000000004 0000000002 y Sep 29 19:03:02 Net_NNTP [debug] C: QUIT Sep 29 19:03:02 Net_NNTP [debug] S: 1st time: Stops after 10,600th newsgroup 2nd time: Stops after 850th newsgroup 3rd time: Stops after 1,464th newsgroup etc etc I ran the same script on PHP 5.2.10 few times and it fetched all 107k newsgroups fine, not sure why doesn't work on 5.2.11 SOURCE CODE ========== require_once('Log.php'); require_once('Net/NNTP/Client.php'); $file = &Log::factory('file', 'log.txt', 'Net_NNTP'); $nntp = new Net_NNTP_Client(); $nntp->setLogger($file); $nntp->connect('news.example.com', false, 119); $nntp->authenticate('username', 'password'); $server_newsgroups = $nntp->getGroups(); $nntp->quit(); if (PEAR::isError($server_newsgroups)) { echo 'Fetching list of groups failed: ' . $server_newsgroups->getMessage(); exit; } foreach ($server_newsgroups as $server_newsgroup) { $newsgroups[] = $server_newsgroup['group']; } natcasesort($newsgroups); file_put_contents('output.txt', implode("\r\n", $newsgroups));
 [2009-09-30 01:08 UTC] ddfly (Jim Jones)
-PHP Version: 5_2 CVS-2009-09-29 +PHP Version: 5.2.11
 [2009-09-30 01:08 UTC] ddfly (Jim Jones)
-Status: Feedback +Status: Open
 [2009-09-30 03:12 UTC] heino (Heino H. Gehlsen)
If you are sure the server actually rthe terminating peiod, my guess would be that you might be thrown out of the while loop in the _getTextResponse() method because of no more data available. It’s only a desperate thought however… Could you please try to make an eternal loop at NNTP/Protocol/Client.php line 321? Change while(!$this->_socket->eof()) { into while (true) { You could also try to increase the socket timeout: $nntp->_socket->setTimeout($seconds, $microseconds); (http://pear.php.net/manual/en/package.networking.net-socket.settimeout.php)
 [2009-09-30 12:19 UTC] ddfly (Jim Jones)
while (true) That seems to have fixed the problem. Tested it many times and it fetched all 107k newsgroups fine, reverting it back saw the problem return. Changing the socket timeout had no effect.
 [2009-09-30 14:06 UTC] ddfly (Jim Jones)
http://bugs.php.net/bug.php?id=49706 According to above, feof() is bad in 5.2.11 which is what Net_Socket uses on line 431 for eof()
 [2009-09-30 23:58 UTC] ddfly (Jim Jones)
-Status: Open +Status: Closed -Assigned To: +Assigned To: ddfly
 [2009-10-04 15:45 UTC] heino (Heino H. Gehlsen)
-Status: Closed +Status: Bogus
Thank you for taking the time to report a problem with PHP. Unfortunately you are not using a current version of PHP -- the problem might already be fixed. Please download a new PHP version from http://www.php.net/downloads.php If you are able to reproduce the bug with one of the latest versions of PHP, please change the PHP version on this bug report to the version you tested and change the status back to "Open". Again, thank you for your continued support of PEAR. Added E_USER_WARNING about PHP version 5.2.11 and changed error message to reflect actual situation...
 [2012-01-16 03:45 UTC] heino (Heino H. Gehlsen)
Fix: Change line 72 from: if (version_compare(PHP_VERSION, '5.2.11') === 1) { to: if (version_compare(PHP_VERSION, '5.2.11') === 0) {