Posts Tagged ‘modded’

WordPress 2.3 and array_merge() issues in widgets.php

Alright! I’ve upgraded to version 2.3, and I’m in the process of migrating from the K2 Beta Two theme to a modded version of Cutline.

Anyway, the upgrade was almost painless. I say almost, because for a few minutes I had an ugly PHP error flashing across the top of every page on the site. And when I logged out at one point, I was prevented from logging back in(!).

So here’s the problem: this server rune PHP5 (5.1.6, to be precise). PHP5 throws a hissy fit if you try to use array_merge() to merge variables that aren’t explicitly arrays. WordPress 2.3’s wp-includes/widgets.php file does this very thing.

So how’d I fix it? After digging around the articles at PHP.net, I went into the widgets.php file and changed line #53 from
$sidebar = array_merge($defaults, $args);
to
$sidebar = array_merge((array)$defaults, (array)$args);
and it seems to have fixed things.

Just wanted to mention this in case other WordPress users like me start pulling out their hair over it. I probably still have a few more issues to track down (seems something keeps trying to use the post2cat table when comments are submitted, hmm…), but I’m happy. :)

(Update: still an issue with WordPress 2.5.)