Hi,

in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument in /var/www/includes/common.inc(1655) : eval()'d code on line 9.

My logs are littered with this same message. I have no idea what it means. When I visit the common.inc file, I see this module:

function drupal_eval($code) {
  global $theme_path, $theme_info, $conf;

  // Store current theme path.
  $old_theme_path = $theme_path;

  // Restore theme_path to the theme, as long as drupal_eval() executes,
  // so code evaluted will not see the caller module as the current theme.
  // If theme info is not initialized get the path from theme_default.
  if (!isset($theme_info)) {
    $theme_path = drupal_get_path('theme', $conf['theme_default']);
  }
  else {
    $theme_path = dirname($theme_info->filename);
  }

  ob_start();
  print eval('? >'. $code); //added space for forum display
  $output = ob_get_contents();
  ob_end_clean();

  // Recover original theme path.
  $theme_path = $old_theme_path;

  return $output;
}

It points to the Print eval line. Does anyone know when and why this is called? If I understand that I might be able to work backwards.

Thanks,
Paul.

Comments

michelle’s picture

You have some code that is being evaluated that has an error in it. Like when you put code into a block or a node using the php input format. It would be line 9 of that code that's broken.

Michelle

techypaul’s picture

Thanks michelle, thats really great - I discovered it was a mistake in my menu converting from nid to clean url. All fixed now.

Thanks,
Paul.

p.s. as you're reading, just a quick thanks for the advanced forum, a very useful module :).

techypaul’s picture

Just wanted to update this - it wasnt what I first thought. I continued to get errors. I started removing all code from my front page (literally) and was still getting the error. I realized it was only coming from the Admin user, so I cleared the Admin Menu module cache and suddenly it is all working again, so maybe a uninstall or disabled module left something.

Thanks for the help.

Paul.

michelle’s picture

Glad you got it working. :)

Michelle

techypaul’s picture

Hi,

I thought I had this licked, but its still coming up. I cleared my entire page tpl and ran it, so there is nothing coming up when I refresh but the error is still appearing. There are no blocks on that page, only views and the static html that I have removed. I assume views wouldnt run because its not being called in the template.

Any idea what drupal runs through, even if not being displayed/used?

Thanks,
Paul.

karynberger’s picture

How do I resolve this?

ressa’s picture

Thanks for the hint Michelle. I started getting the error message: warning: in_array() [function.in-array]: Wrong datatype for second argument in /var/www/theme/includes/common.inc(1685) : eval()'d code on line 3.

It showed up three times on certain pages and only one time on others. It turned out I had forgotten to qualify when to execute a check of when to show a block, using php. This was being run on every page now:

$userpage = user_load(array('uid' => arg(1)));
if (in_array('partner',$userpage->roles)) {   
  // this is a partner role being viewed
  return TRUE;
  }

...the error came because arg(1), which the 'user_load' object needs, only exists on user pages, where the path alias is users/'username', and the "real" path is for example user/66. Checking that a user page is being viewed fixed the problem:

if (arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0) { // is a user page
  $userpage = user_load(array('uid' => arg(1)));
  if (in_array('partner',$userpage->roles)) {   
    // this is a partner role being viewed
    return TRUE;
  }
}  
techypaul’s picture

Still getting this error. Been through every block and there is no PHP at all anymore and its still coming up, I have this backtrace;

Backtrace: in_array(a:2:{i:0;N;i:1;N;})[common.inc(1685) : eval()'d code:9] <=eval()[common.inc:1685] <=drupal_eval(...)[block.module:440] <=block_list(...)[theme.inc:1580] <=theme_blocks(...)[:] <=call_user_func_array(...)[theme.inc:617] <=theme(...)[template.php:102] <=totally_techy_preprocess_node(...)[:] <=call_user_func_array(...)[theme.inc:658] <=theme(...)[node.module:1023] <=node_view(...)[content_profile.theme.inc:57] <=content_profile_preprocess_content_profile_display_view(...)[:] <=call_user_func_array(...)[theme.inc:658] <=theme(...)[common.inc:2898] <=drupal_render(...)[common.inc:2907] <=drupal_render(...)[user.pages.inc:188] <=template_preprocess_user_profile(...)[:] <=call_user_func_array(...)[theme.inc:658] <=theme(...)[user.pages.inc:171] <=user_view(...)[:] <=call_user_func_array(...)[menu.inc:348] <=menu_execute_active_handler(Array)[index.php:18] <=index.php

This happens when there are no blocks actually selected for that page (e.g. a page with no regions, html coded). Would blocks be run through in that situation?

Thanks,
Paul.