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
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

Jose A Reyero - February 20, 2008 - 13:15

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

markus_petrux - April 16, 2008 - 14:24

Here's a possible solution to this:

http://www.php.net/manual/en/function.array-combine.php#82244

<?php
if (!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

peashooter - April 19, 2008 - 12:33

I'm using PHP5 - my site is hosted at www.bluehost.com which apparently only has PHP5.

Any ideas?

Cheers

#4

Jose A Reyero - April 21, 2008 - 15:18
Status:active» fixed

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

Anonymous (not verified) - May 5, 2008 - 15:25
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.