Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I'm getting a bunch of PHP errors every time the cron runs. I can't seem to track down what is causing them all.

Cannot use a scalar value as an array in drupal_render() (line 5822 of /var/www/vhosts/tlthost.net/httpdocs/includes/common.inc).

Cannot use a scalar value as an array in drupal_render() (line 5767 of /var/www/vhosts/tlthost.net/httpdocs/includes/common.inc).

Invalid argument supplied for foreach() in element_children() (line 6300 of /var/www/vhosts/tlthost.net/httpdocs/includes/common.inc).

Cannot use a scalar value as an array in adaptivetheme_page_alter() (line 235 of /var/www/vhosts/tlthost.net/httpdocs/sites/all/themes/at_core/inc/alter.inc

Cannot use a scalar value as an array in user_relationships_ui_page_alter() (line 247 of /var/www/vhosts/tlthost.net/httpdocs/sites/tlt/modules/user_relationships/user_relationships_ui/user_relationships_ui.module).

Cannot use a scalar value as an array in fbconnect_page_alter() (line 568 of /var/www/vhosts/tlthost.net/httpdocs/sites/all/modules/fbconnect/fbconnect.module).

Cannot use a scalar value as an array in block_page_build() (line 269 of /var/www/vhosts/tlthost.net/httpdocs/modules/block/block.module).

I'm hoping maybe if you folks know what's causing this one, it might help me figure out the rest of the errors.

share|improve this question

2 Answers 2

Sometimes these error messages come up on my sites if cron is run while the site is in maintenance mode. I'm guessing the maintenance mode template for our site has something to do with it, but it could be a variety of things.

When cron runs, it is still running through Drupal's theme system, so you probably have something awry in either your theme or one of your custom modules. Does this happen every time cron runs, or just sometimes?

A final troubleshooting step would be to install elysia_cron and run each cron task individually to see which one might be causing all these errors.

See also: Warning: Cannot use a scalar value as an array

share|improve this answer
    
Thanks. I'll have to wait and see what happens when it's not in maintenance mode. That's been delayed because I ran into a huge code problem. I get info from Amazon, and they just changed their API in a way that killed all I had done. –  TomP Dec 7 '12 at 15:09
    
Ouch! Well, hopefully it works out for you. –  geerlingguy Dec 7 '12 at 20:02
    
FWIW, this problem is still around (Drupal 7.31). I'm getting scalar-as-array warnings from inside drupal_render(), element_children(), ctools_page_alter(), and ckeditor_page_build(). Everything is fine when I'm not in maintenance mode. I might dig into this, but, to be honest, it's not near the top of my list... –  Jim Miller Sep 9 at 1:22

That error occurs when you use a stdClass() type object as an array.

e.g

Given a node object:

$node->title = 'foo'; // right
$node['title'] = 'foo'; // wrong

Perhaps that will help debug the solution, maybe it's a php syntax issue in a hook_cron implementation

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.