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

Bug #692 testing strlen on array create unwanted warning in weatherdotcom module
Submitted: 2004-02-06 03:53 UTC
From: fischaz at fischaz dot com Assigned:
Status: Bogus Package: Services_Weather
PHP Version: 4.3.4 OS: Debian GNU/Linux
Roadmaps: (Not assigned)    
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:
Solve the problem : 15 - 4 = ?

 [2004-02-06 03:53 UTC] fischaz at fischaz dot com
Description: ------------ In the function _checkLocationID($id) which test if $id is a valid location (a string). The test is made using the strlen func. This function create a warning output if $id is an array (case of multiple locations returned by or an object (pear_error object) The test would be better by hiding the warning or changing the function to a more suitable (like a gettype() or is_a()). Reproduce code: --------------- $location = 'Paris, France'; $weatherDotCom = &Services_Weather::service("WeatherDotCom"); $weatherDotCom->setAccountData($id, $key); $weatherDotCom->searchLocation($location); $result = $weatherDotCom->getLocation($search); ... Expected result: ---------------- The function just return the pear_error object for a bad location without any display messages Actual result: -------------- Notice: Array to string conversion in /usr/share/php/Services/Weather/Weatherdotcom.php on line 160 (ps: I added some debug code just before, so the error normally would be at line 149 I think). I'm also in a E_ALL environment.


 [2004-02-06 10:56 UTC] eru at php dot net
The getLocation (and _checkLocationID as well) function header clearly states, that it expects a string as input, so if you pass an object or array don't be suprised if you get an error - I won't start adding typechecking everywhere. Likewise the searchLocation function is marked as returning either a string or an array, you have to do the differentiation on your own. Thanks for your report anyway ;-)