Travis Seitler [photo]

Travis Seitler is a twenty-something guy living in Marietta, PA with his wife and two kids. Since 2003 He's been writing here about God, government and comic books. You can read more about him if you really want to, and you're invited to drop him a line, like, whenever!

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.)

Popularity: 7% [?]

Tagged: · · · · · · · · ·

2 Comments so far

  1. Nicole Seitler on September 25th, 2007

    Whoa! This looks different… and BIG!

  2. Brady on August 5th, 2008

    Thanks! To add:

    I modified the code above in file:

    wp-includes/widgets.php

    Worked like a charm!

Leave a Reply