Volunteer module crashes out server

Steve Dondley - September 1, 2006 - 14:42
Project:volunteer
Version:HEAD
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:active
Description

With PHP4, I get the following error:

Fatal error: Cannot redeclare array_walk_recphp4() (previously declared in /home/unionsites/public_html/modules/volunteer/volunteer.module:1269) in /home/unionsites/public_html/modules/volunteer/volunteer.module on line 1269

Error occurs when trying to view a node/XX/volunteer page.

#1

diarmait - September 13, 2006 - 19:15

I was having a problem that was giving me the same error message. Here is how I fixed mine.

In volunteer.module, I replaced:

// from php.net
// Note: Originally this was split into two functions, however this caused
// infinite looping under PHP 5.1. I've now done a straight copy/paste from
// http://ca3.php.net/manual/en/function.array-walk-recursive.php#48181
function _volunteer_array_mergedown() {
global $outarray;
$outarray = array();
function array_walk_recphp4(&$val,$key) {
global $outarray;
if (is_array($val)) array_walk($val,'array_walk_recphp4');
else {
$outarray[$key] = $val;
}
}
$params = func_get_args();
foreach ($params as $subarr) {
array_walk_recphp4($subarr, '');
}
return $outarray;
}

with:

// from php.net
// Note: Originally this was split into two functions, however this caused
// infinite looping under PHP 5.1. I've now done a straight copy/paste from
// http://ca3.php.net/manual/en/function.array-walk-recursive.php#48181
function _volunteer_array_mergedown() {
global $outarray;
$outarray = array();
$params = func_get_args();
foreach ($params as $subarr) {
array_walk_recphp4($subarr, '');
}
return $outarray;
}

function array_walk_recphp4(&$val,$key) {
global $outarray;
if (is_array($val)) array_walk($val,'array_walk_recphp4');
else {
$outarray[$key] = $val;
}
}

I got this stuff from an earlier version of volunteer.module, and my current version was the now-current cvs 1.58. So, I notice that this was a fix for php5, so would guess that my fix will break php5. As such, I'm not going to offer a fix for anything, but I will say that my code revision works for me. I hope this is helpful to the commenter and to the team.

 
 

Drupal is a registered trademark of Dries Buytaert.