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

Bug #14839 Function CheckHost fails with error every time.
Submitted: 2008-10-21 01:18 UTC
From: clipinski Assigned: cconstantine
Status: Closed Package: Net_Ping (version 2.4.3)
PHP Version: 5.2.6 OS: Windows XP
Roadmaps: 2.4.4    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 41 - 25 = ?

 
 [2008-10-21 01:18 UTC] clipinski (Craig Lipinski)
Description: ------------ The function CheckHost fails with the following error everytime it is called: PHP Fatal error: Cannot use object of type Net_Ping_Result as array in E:\PHP\PEAR\pear\Net\Ping.php on line 425 Test script: --------------- <?php // include class require ("Net/Ping.php"); // create object $ping = Net_Ping::factory(); // ping host and display response if(!PEAR::isError($ping)) { if ( $ping->CheckHost('www.google.com') ) { echo "Google is up!!!"; } else { echo "Google is down..."; } } ?> Expected result: ---------------- Google is up!!! Actual result: -------------- PHP Fatal error: Cannot use object of type Net_Ping_Result as array in E:\PHP\PEAR\pear\Net\Ping.php on line 425

Comments

 [2008-10-21 11:26 UTC] cconstantine (Craig Constantine)
confirmed.
 [2009-01-24 23:02 UTC] iocon (Stede Bonnett)
It appears the function is trying to do too much work, and parsing the _result itself. I was able to fix and test Net/Ping/checkHost once I figured out what it was trying to do - the info it needs is already in the result object. function checkHost($host, $severely = true) { $this->setArgs(array("count" => 10, "size" => 32, "quiet" => null, "deadline" => 10 ) ); $res = $this->ping($host); if (PEAR::isError($res)) { return false; } if ($res->_received == 0) { return false; } if ($res->_received != $res->_transmitted && $severely) { return false; } return true; } /* function checkHost() */
 [2009-01-27 19:30 UTC] cconstantine (Craig Constantine)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net 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. Thank you Stede Bonnett! I've committed the fix to CVS and will release 2.4.4.