5
votes

My full calendar throws errors when seen from the site:

Warning: Invalid argument supplied for foreach() in element_children() (regel 6400 van C:\Users\Simon\My Websites\Xampp\htdocs\xxx\includes\common.inc).
Warning: Illegal string offset '#children' in drupal_render() (regel 5867 van C:\Users\Simon\My Websites\Xampp\htdocs\xxx\includes\common.inc).
Warning: Illegal string offset '#children' in drupal_render() (regel 5877 van C:\Users\Simon\My Websites\Xampp\htdocs\xxx\includes\common.inc).
Warning: Illegal string offset '#children' in drupal_render() (regel 5915 van C:\Users\Simon\My Websites\Xampp\htdocs\xxx\includes\common.inc).
Warning: Illegal string offset '#printed' in drupal_render() (regel 5922 van C:\Users\Simon\My Websites\Xampp\htdocs\xxx\includes\common.inc).

I have read somewhere that it doesn't work well under PHP 5.4xx.

Anyone a solution?

7
Do you use the latest Drupal core version? Have pretty the same issues with php 5.3/5.4 compatibility, and upgrading to the latest Drupal 7.22 did the trick.tulvit
But does the calendar display properly?Subhas
@RDX yes, the calendar show just fine at the bottom...Nomistake
@tulvit I'm running this version, still nog success ;-(Nomistake
@Nomistake posted a solution below, can u pls check if that works?Subhas

7 Answers

17
votes

Better advice is as follows:

1) To hide warnings/errors/notices from users on a live Drupal 7 site, go to [SITE]/admin/config/development/logging and turn off the display of errors. Don't do it in your settings file, as you then lose the ability to find problems.

2) It is often worthwhile to do a bit of debugging. While it is true that, as a general matter, warnings and notices can be safely ignored, they will slow down your site ( see Does php run faster without warnings? ). Often the error is the result of a known problem with a particular Drupal module, and there may be a patch posted on drupal.org that fixes the problem. The source of this particular (and common) bug can be difficult to track down, but there's a helpful discussion for how to do it here: http://fuseinteractive.ca/blog/put-your-children-their-place-drupal-debug-snippet

In your case, it's probably a bug in the Calendar module (assuming that's what you're using to produce your calendar), and you probably want to look at the issue queue there: https://drupal.org/project/issues/calendar?categories=1

4
votes

This is a known issue with PHP/Drupal. All the errors that you see are not errors, they're just warnings and can be very safely ignored. You only need to be concerned with lines that start with Error: .....

To safely ignore these warnings, edit your drupal sites/default/settings.php and add the following line:

error_reporting(E_ALL & ~(E_STRICT|E_NOTICE|E_WARNING));

This will also resolve the same issue for potentially other plugins too.

The recommended production setting for Drupal is to disable error reporting altogether, so that your users don't get any cryptic error messages. For a production Drupal site, you must do:

error_reporting(0);

And if you need to see errors in your website, use the nginx logs instead.

Edit: Fix error_reporting, add production notes

3
votes

It looks like you are trying to render elements that does not have the proper array layout. Try to use debug_backtrace() and debug_print_backtrace() to find the code that is causing the warnings.

Also you can also uninstall modules and see when the error does away. Be sure to clear your cache to be sure you are not fooled by anything.

Other commands you can use is dd() dpm() krumo() from the devel-module.

Also look at: http://php.net/display-errors and http://php.net/display-startup-errors

David

1
votes

Adding this patch to the common.inc helped me fix my problems

diff --git a/includes/common.inc b/includes/common.inc
index c6303ef..e8f7e66 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -6007,7 +6007,9 @@ function drupal_render(&$elements) {
 // for speed.
 if ($elements['#children'] == '') {
 foreach ($children as $key) {
-      $elements['#children'] .= drupal_render($elements[$key]); 
+      if (is_array($elements[$key])) {
+        $elements['#children'] .= drupal_render($elements[$key]);
+      }
     }
   }
0
votes

I was getting tons of similar warnings with Drupal 7.23 and PHP 5.4, especially from Panels. I just changed the PHP version from 5.4 to 5.3 (single php.ini) in the cPanel/PHP Config and all these warnings and notes disappeared.

0
votes

Whether it helps I don't know, but I had a similar error message, it was due to me changing the machine name of a content type.... I reverted to the previous backup, which had the content type altered as well, deleted it, recreated it with the intended name and all is good

0
votes

Related issue: in module commons_events, equivalent error messages were triggered by a migration from PHP 5.3 to 5.4 and fixed in #1995834: PHP 5.4 Attend an Event page errors to screen in comment #13.