The function failing is at nws_weather.module lines 976-989:
/**
*
*/
function nws_weather_override_image($image) {
if ($override = variable_get('nws_weather_override_bool', 0)) {
$result = db_query("SELECT img FROM {nws_weather_config} WHERE url = '%s'", $image);
$row = db_fetch_array($result);
$directory = variable_get('nws_weather_override_directory', NWS_WEATHER_OVERRIDE_DIRECTORY_DEFAULT);
// Need $override switch set before will override image.
if ($override && $fname = $row['img']) {
$image = $directory . '/' . $fname;
}
}
return $image;
The db_query and db_fetch_array calls are both still formatted for D6 and fail with D7. db_query expects arguments to be passed in an array and db_fetch_array no longer is supported in D7. The changes below pass the query argument in an array, replace the db_fetch_array with a $result->fetchfield(), and inserts a test to see if the field was successfully retrieved.
I changed the function to:
/**
*
*/
function nws_weather_override_image($image) {
if ($override = variable_get('nws_weather_override_bool', 0)) {
$result = db_query('SELECT n.img FROM {nws_weather_config} n WHERE n.url = :url', array(':url'=>$image));
$newimage = $result->fetchfield();
if ($newimage) {
$directory = variable_get('nws_weather_override_directory', NWS_WEATHER_OVERRIDE_DIRECTORY_DEFAULT);
// Need $override switch set before will override image.
if ($override && $fname = $newimage) {
$image = $directory . '/' . $fname;
}
}
}
return $image;
One of these days I'm going to figure out how to develop a patch! For now, this will have to do.
Comments
Comment #1
jimsmith commentedHere's a patch of @David4514's fix. Looks to me like it works.
Comment #2
dwaine commentedThank you for debugging my relatively obvious bug. If nothing else the length of time this bug stayed hidden demonstrates how few users are choosing to override the default images. I have updated the code in the version control system and the next release will include this bug fix.
Comment #3
juahoo commentedI had this issue in a fresh install of 7.x-1.3. I applied the patch and it corrected the error.
Comment #5
jerry commentedPatch is working here as well, so marking as RTBC. Note: this patch must be applied from Drupal root.
Comment #6
spacemuon commentedComment #1 patch worked for me. Thanks JimSmith.
Note: Applied patch from the sites/all/modules/nws_weather directory.
Comment #7
aaronrus commentedClosing as outdated — the branch this issue was reported against is no longer supported. The module is now maintained on the 2.x-dev branch.
Thank you for your report!