PHP 4 compatibility
chirale - February 17, 2008 - 07:56
| Project: | Notifications |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
This happens when I try to subscribe to a content type via Notifications UI.
Fatal error: Call to undefined function: array_combine() in /var/www/mydir/drupal/sites/mysite/modules/notifications/notifications.admin.inc on line 365
Simply, array_combine() is available only on PHP 5. I see other similar errors on this module, so a PHP4 user cannot use this module at all for (few) functions written for PHP5. Can you use a backward-compatible alternatives for these?

#1
For now, I'v just added the PHP 5.x requirement to the module description.
Willing to fix it as long as someone else provides a patch. The problem is my dev environment is PHP5 only from some time ago, so I cannot even test for PHP4.
#2
Here's a possible solution to this:
http://www.php.net/manual/en/function.array-combine.php#82244
<?phpif (!function_exists('array_combine')) {
function array_combine($arr1, $arr2) {
$out = array();
$arr1 = array_values($arr1);
$arr2 = array_values($arr2);
foreach($arr1 as $key1 => $value1) {
$out[(string)$value1] = $arr2[$key1];
}
return $out;
}
}
?>
#3
I'm using PHP5 - my site is hosted at www.bluehost.com which apparently only has PHP5.
Any ideas?
Cheers
#4
Thanks, just copied and pasted the code in the module, I guess it won't break anything else..
(I just wish we had some php4 compatibility drupal module which had all these functions...)
#5
Automatically closed -- issue fixed for two weeks with no activity.