Warning: Invalid argument supplied for foreach() in _block_rehash() (line 336 of block.module).

because statistics_block_info() function may return NULL

CommentFileSizeAuthor
#10 test.php_.txt327 bytespasqualle
statistics_block_info.patch791 bytespasqualle

Comments

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Manual testing fixed the issue. Patch looks fine.

attheshow’s picture

Still getting this error even with this patch installed. Whenever I try to configure blocks. Wasn't happening in Alpha 3. Only in Alpha 4.

webchick’s picture

Status: Reviewed & tested by the community » Needs review

Hm. That sounds like a needs work? Or at least a needs review?

The patch looks pretty sane to me, though.

jpamental’s picture

I'm running a very fresh (today) install of alpha 4 - was getting this error and tried the patch (on the statistics module, not the block module) and it cleared it right up. No errors anymore.

dries’s picture

Status: Needs review » Fixed

The code in the patch is valid. If there is still a problem, it ought to be an additional problem. Therefore, I decided to commit this patch to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)

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

henrijs.seso’s picture

Status: Closed (fixed) » Active

It looks like this warning is back again. Drupal 7.9 after installing modules.

zil0484’s picture

yes i got this problem also with 7.9. pls solve this

pasqualle’s picture

can you tell the full error message? I would like to know the line number, as there are more foreach loops in _block_rehash().

pasqualle’s picture

StatusFileSize
new327 bytes

if it is the same error, then running the attached file will tell you which module has a wrong hook_block_info() implementation.
- rename the file to test.php, copy it into the Drupal root folder and open it in the browser (mysite.com/test.php)

tungpham42’s picture

Version: 7.x-dev » 7.7

I got this same error message on Drupal 7.7 every time I install new modules.
Warning: Invalid argument supplied for foreach() in _block_rehash() (line 385 of /mysite/modules/block/block.module)

Juan C’s picture

I also had this error: "Warning: Invalid argument supplied for foreach() in _block_rehash() (line 385 of /mysite/modules/block/block.module)"

#10 help me find the culprit. Thanks.

yahya.akhtar’s picture

Status: Active » Needs review

statistics_block_info.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, statistics_block_info.patch, failed testing.

yahya.akhtar’s picture

Status: Needs work » Needs review

statistics_block_info.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, statistics_block_info.patch, failed testing.

stevenjohn’s picture

Be great to get this fixed, I also have the same issue:

Warning: Invalid argument supplied for foreach() in _block_rehash() (line 385 of /public_html/modules/block/block.module).

When i tested where the error was coming from it says its the Linkedin module...

Steve

Rhino’s picture

I just installed the linkedin module on a clean Drupal 7 install and got:

Warning: Invalid argument supplied for foreach() in _block_rehash() (line 389 of /drupal/htdocs/modules/block/block.module).

pasqualle’s picture

oscardax’s picture

Thanks Pasqualle!!
I had a custom module not returning anything in hook_block_info() and so I was getting the warning.

dddave’s picture

Status: Needs work » Closed (fixed)

This isn't a core issue but a contrib issue. Resetting correct status.