Fixing a broken dashboard in Wordpress 2.5

Posted by – April 10, 2008

WordpressSince upgrading to Wordpress 2.5 last week (which, incidentally, is excellent), my administrator dashboard has been somewhat broken returning the error:

Fatal error: Unsupported operand types in /path/to/blog/wp-admin/index.php(101) : runtime-created function on line 1

Well, I’ve been looking at this tonight and sussed the problem.  Let’s take a look at line 101 (ignore the word wrap):

$num_widgets = array_reduce( $sidebars_widgets, create_function( '$prev, 
$curr', 'return $prev+count($curr);' ) );

Now, from what I can tell, this line is figuring out how many widgets to show, and thus figure out the HTML etc required to do so.  However, in PHP, array_reduce() will return NULL if nowt is found, and an initial value argument is not passed in.  Passing in an initial value fixes this (0 being that default):

$num_widgets = array_reduce( $sidebars_widgets, create_function( '$prev, 
$curr', 'return $prev+count($curr);' ), 0 );

Stick that in your code, and all should be running smoothly.

0 Comments on Fixing a broken dashboard in Wordpress 2.5

Closed