after Language Switcher Dropdown module 7.x-2.1 checkbox setted on site showed only next line and nothing else: "Fatal error: Call to undefined function array_replace_recursive() in ./sites/all/modules/lang_dropdown/lang_dropdown.module on line 666".

Google search gave an answer like this : https://drupal.org/node/1541594 [... array_replace_recursive is only available for php >= 5.3 and thus does throw error on older servers. Since 5.2 is the minimu requirement for drupal I would suggest replacing this with something else.] ... on my host used PHP 5.2.17

to solve this trouble i simple Append next code (getted from https://drupal.org/node/1541594) to module ./sites/all/modules/lang_dropdown/lang_dropdown.module :
/*
* pre php5.3
*/
if (!function_exists('array_replace_recursive')) {
function array_replace_recursive($array, $array1) {
// handle the arguments, merge one by one
$args = func_get_args();
$array = $args[0];
if (!is_array($array)) {
return $array;
}
for ($i = 1; $i < count($args); $i++) {
if (is_array($args[$i])) {
$array = recurse($array, $args[$i]);
}
}
return $array;
}
function recurse($array, $array1) {
foreach ($array1 as $key => $value) {
// create new key in $array, if it is empty or not an array
if (!isset($array[$key]) || (isset($array[$key]) && !is_array($array[$key]))) {
$array[$key] = array();
}
// overwrite the value in the base array
if (is_array($value)) {
$value = recurse($array[$key], $value);
}
$array[$key] = $value;
}
return $array;
}
}

//END php code
P.S. Please fix this issue on module to all

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

manfer’s picture

manfer’s picture

Status: Active » Fixed
manfer’s picture

Fixed a mistake on previous patch. All has been commited and 7.x-2.3 version should resolve this problem by providing an alternative function to array_replace_recursive when PHP version on server doesn't provide array_replace_recursive function.

igl_czech’s picture

Tnanks for update ! after update module to ver.7.x-2.4 im enable Only "Language Switcher Dropdown" and "Language Switcher Dropdown Hideout
" - Not enabled => module working better , "Language Switcher Dropdown" Box showing on page , but in version 7.x-2.4 generate some Notice's and Warnings (on my PHP 5.2.17) :

•Notice: Undefined variable: new_values in _lang_dropdown_array_replace_recursive() (line 966 of ./sites/all/modules/lang_dropdown/lang_dropdown.module).
•Warning: Missing argument 3 for _lang_dropdown_array_replace_recursive(), called in ./sites/all/modules/lang_dropdown/lang_dropdown.module on line 975 and defined in _lang_dropdown_array_replace_recursive() (line 963 of ./sites/all/modules/lang_dropdown/lang_dropdown.module).
•Warning: Missing argument 3 for _lang_dropdown_array_replace_recursive(), called in ./sites/all/modules/lang_dropdown/lang_dropdown.module on line 986 and defined in _lang_dropdown_array_replace_recursive() (line 963 of ./sites/all/modules/lang_dropdown/lang_dropdown.module).

IF i enable addition "Language Switcher Dropdown Hideout" - 7.x-2.4 generate much more Notice's and Warnings :

•Notice: Undefined offset: 2 in lang_dropdown_hideout_language_switch_links_alter() (line 159 of ./sites/all/modules/lang_dropdown/lang_dropdown_hideout/lang_dropdown_hideout.module).
•Notice: Undefined variable: new_values in _lang_dropdown_array_replace_recursive() (line 966 of ./sites/all/modules/lang_dropdown/lang_dropdown.module).
•Warning: in_array() [function.in-array]: Wrong datatype for second argument in lang_dropdown_hideout_language_switch_links_alter() (line 159 of ./sites/all/modules/lang_dropdown/lang_dropdown_hideout/lang_dropdown_hideout.module).
•Warning: Missing argument 3 for _lang_dropdown_array_replace_recursive(), called in ./sites/all/modules/lang_dropdown/lang_dropdown.module on line 975 and defined in _lang_dropdown_array_replace_recursive() (line 963 of ./sites/all/modules/lang_dropdown/lang_dropdown.module).
•Warning: Missing argument 3 for _lang_dropdown_array_replace_recursive(), called in ./sites/all/modules/lang_dropdown/lang_dropdown.module on line 986 and defined in _lang_dropdown_array_replace_recursive() (line 963 of ./sites/all/modules/lang_dropdown/lang_dropdown.module).

manfer’s picture

Sorry. Just change line 963 of lang_dropdown.module from:

  function _lang_dropdown_array_replace_recursive( $defaults, $old_values, $new_values ) {

to:

  function _lang_dropdown_array_replace_recursive( $defaults, $old_values = array(), $new_values = array() ) {

Patch has been attached.

Thanks for the report.

manfer’s picture

New patch that solves the issue on language switcher dropdown hideout module too.

In lang_dropdown_hideout module we have to change line 159 from:

      if (!in_array($langcode, $hidden_languages[$key])) {

to:

      if ( !isset($hidden_languages[$key]) || !in_array($langcode, $hidden_languages[$key]) ) {
manfer’s picture

Status: Fixed » Needs review
manfer’s picture

Category: Support request » Bug report
igl_czech’s picture

many thanks! implemented your latest patches on ver.7.x-2.4 and all working fine!

manfer’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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