Hello,

i used this module in combination with adsense module + revenue sharing. By activating ajax blocks and block configuration return my site folowing error on every pageload and the block content (advertisment) is not show on:

Notice: Array to string conversion in ajaxblocks_ajax_handler() (Zeile 276 von /drupal-7/sites/all/modules/ajaxblocks/ajaxblocks.module).

With other block items (images, other js scripts) this module works fine.

What goes wrong here?

Greetings
Frank

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Frank.dev’s picture

Could the problem may be related to the PHP version 5.4 I use?

Emilio13’s picture

Have the same problem, but I dont use Adsense module.
I use PHP 5.4 - I think problem related to that. Like this problem - https://drupal.org/node/1511396

Emilio13’s picture

I'm edit ajaxblocks.module - after

if (array_key_exists('settings', $js)) {
        $settings_new = $js['settings']['data'];
      }

add:

$array_mapping_func = (function_exists('drupal_array_diff_assoc_recursive')) ? 'drupal_array_diff_assoc_recursive' : 'array_diff_assoc';

And replace

$settings_diff = array_diff_assoc($settings_new, $settings_old);

with:

$settings_diff = call_user_func_array($array_mapping_func, array($settings_new, $settings_old));

Seems like it solve my problem.

Frank.dev’s picture

Thank you, Emilio, after I insert the changes disappear the error messages. :-)
However, advertising is not yet displayed.

Adsense is set up correctly and I suspect that the script of the ads do not just play along here.

seanbfuller’s picture

Title: compatibility with adsense module? » Compatibility with PHP 5.4
Status: Active » Needs review
FileSize
870 bytes

Changing the title as this definitely seems to be an issue with PHP 5.4. Attached is a patch based on #3. Marking s needs review. Thanks!

marcoka’s picture

fixed the notices here.

mjgruta’s picture

I'm not sure if we really need to do this as "drupal_array_diff_assoc_recursive" is already part of Drupal and will always be true.

<?php
$array_mapping_func = (function_exists('drupal_array_diff_assoc_recursive')) ? 'drupal_array_diff_assoc_recursive' : 'array_diff_assoc';
?>

I used this code instead.

<?php
$settings_diff = call_user_func_array('drupal_array_diff_assoc_recursive', array($settings_new, $settings_old));
?>

or use it directly.

<?php
$settings_diff = drupal_array_diff_assoc_recursive($settings_new, $settings_old);
?>
spesic’s picture

#5 worked for me.

greenmother’s picture

#5 helped me, thank you seanbfuller

egontinno’s picture

#5 worked for me.

chriso’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

@jhayzon - that function only became available in Drupal 7.23 (#1850798-90: Add a recursive version of array_diff_assoc()) so it might be sane to leave the check in there.

#5 patch has been working for me too for a while, and I've just checked it again against a fresh 1.x-dev. Setting as RTBC.

gausarts’s picture

+1 RTBC for #5. Thanks

W.M.’s picture

#5 solved the problem here. Strange, I was getting the error message only over http protocol. Under https no error was logged to dblog.

My system is PHP 5.6.2.

cwoky’s picture

FileSize
826 bytes

#5 The patch doesn't work with 'drush make' command.
Here is a new patch that work with 'drush make' command.

  • maximpodorov committed 4c93616 on 7.x-1.x
    Issue #2149593 by seanbfuller: Use drupal_array_diff_assoc_recursive()...
maximpodorov’s picture

Status: Reviewed & tested by the community » Fixed

#5 is committed: http://drupalcode.org/project/ajaxblocks.git/commit/4c93616
Thank you for your patience.

  • maximpodorov committed 53d4ee4 on 6.x-1.x
    Issue #2149593 by seanbfuller: Use drupal_array_diff_assoc_recursive()...
maximpodorov’s picture

The similar solution is committed in 6.x-1.x: http://drupalcode.org/project/ajaxblocks.git/commit/53d4ee4

Status: Fixed » Closed (fixed)

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