[wp-hackers] PHP4->5 - Apache 2.2.2 --> MySql 5.x -- WP Upgrades

Christopher J. Hradil chradil at comcast.net
Sat Jul 15 00:39:29 GMT 2006


To all --
thanks for the input. 

in terms of a little follow up, everything seems to work OK with 2.2.2
Apache platform as well as the other items mentioned, 
there are some quirks here and there depending on your specific platform
(I've tested on both redhat linux and Win XP/Apache/MySQL)

I would suggest that anyone considering upgrading from the 1.3xx branch of
Apache just go ahead and make the move to 2.2.2. I've noted similar
performance gains as mentioned in at least one earlier post as well. Also
have tested xoops, coppermine photo gallery, phpBB, gallery 2, sugar crm,
and a couple of other apps I commonly use for clients using the most current
versions and as noted below, everything works, no major issues. 

I would make one suggestion to anyone considering these upgrades in addition
to just skipping over the 2.0.x apache version, do a SQL dump of your
existing databases (data and structure) prior to the upgrades. I've found
that especially with WP (I think the two offending plugins were WP-Cache and
extended-archives) it was just easier to do a clean install then drop the
new tables created in the db, then import the old tables. I did this process
for a couple of sites and everything is perfect. 


best....chris


/**************************************
Christopher J. Hradil
chradil at comcast.net
http://www.hradil.us
973-809-4606
**************************************/


-----Original Message-----
From: wp-hackers-bounces at lists.automattic.com
[mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of Angsuman
Chakraborty
Sent: Friday, July 14, 2006 2:13 PM
To: wp-hackers at lists.automattic.com
Subject: RE: [wp-hackers] PHP4->5 upgrade heads up && another change
oftopic---

> by the way, have you (or anyone on the list) been using or upgraded to 
> MySQL
5.xx branch ?  Any issues/quirks, etc ?

I did. No problems with WordPress or Mambo / Joomla as far as I could see.

Best,
Angsuman

-----Original Message-----
From: wp-hackers-bounces at lists.automattic.com
[mailto:wp-hackers-bounces at lists.automattic.com]On Behalf Of Christopher J.
Hradil
Sent: Friday, July 14, 2006 5:33 AM
To: wp-hackers at lists.automattic.com
Subject: RE: [wp-hackers] PHP4->5 upgrade heads up && another change of
topic---
Importance: Low


I've purposely avoided php5 for now for a number of reasons, but this is
useful info, as I have seen a similar problem with a couple of folks using
php5, and I think this might be a good "quick fix". thanks...

by the way, have you (or anyone on the list) been using or upgraded to MySQL
5.xx branch ?  Any issues/quirks, etc ?

I have a big project coming up that I'd like to be using 5.xx for but I'm a
little afraid to upgrade my dev box (which I have my live personal site on)
because it's also going to mean rebuilding php and a couple of other things
on the box. 

..chris 


/**************************************
Christopher J. Hradil
chradil at comcast.net
http://www.hradil.us
973-809-4606
**************************************/


-----Original Message-----
From: wp-hackers-bounces at lists.automattic.com
[mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of Brian Layman
Sent: Thursday, July 13, 2006 5:56 PM
To: wp-hackers at lists.automattic.com
Subject: [wp-hackers] PHP4->5 upgrade heads up

On a related topic, I've been meaning to mention the widgets problem I'd
discussed with Andy Skelton.  In the end it was related to the change in
array_merge between PHP4 and PHP5 and could occur in anyone's code.  So, if
someone missed this array_merge change, I thought a public post might be
beneficial...  

PHP5's array_merge now blows up on non-array variables.  It seems some PHP
array functions, specifically array_slice, return non-array (unset)
variables.  So, in short, an array_merge that works in php4 may not work in
php5 unless you follow the same convention Mark Jaquith recommended when he
said "cast to array before foreach".  

If a variable's content hasn't already been verified as containing an array,
you should cast to array before using it in an array_merge.  
That could look like this:
  $result = array_merge(array('a'=>1,'b'=>2), (array) $second);

Details on the change can of course be seen here:
http://us2.php.net/array_merge

I'm sure this is old news for some. So, unless you want details of what we
changed, you probably won't care to read on.

---- 

For a practical example, we could look at the now fixed issue from
widgets.php.

An array slice was done in a fashion similar to this:
  $registered_widgets[$name]['params'] => array_slice(func_get_args(), 2)

We are assuming that the problem arose when the 2 argument was defaulted to
''.

The line that actually blew up was this one:
 $params = array_merge(array($sidebar),
$registered_widgets[$name]['params']);

The error was:
"Warning: array_merge() [function.array-merge]: Argument #2 is not an array
in ./wp-content/plugins/widgets/widgets.php on line 154"

There is nothing that indicates array_slice changed between 4 and 5.  So, it
appears the only difference was in array_merge.  Wrapping the error line in
an "if (is_array($registered_widgets[$name]['params']))" solved the problem,
but it was not the fix we used.

I remembered Mark's coding style suggestion for foreach in
(http://comox.textdrive.com/pipermail/wp-hackers/2006-July/006930.html) and
applying it solved the problem in a simpler fashion.  Andy checked in this
new line:
  $params = array_merge(array($sidebar), (array)
$registered_widgets[$name]['params']);

FYI, we'd tried this first:
  $registered_widgets[$name]['params'] => (array)
array_slice(func_get_args(), 2) but it had no affect.

-

I looked at every instance of array_merge in the 2.03 code, and it seems
that all of them are in places where the parameters are guaranteed to have
either a value or array() specified.  So, this is mostly a heads up to
plugin authors.  I haven't done any examination of the plugin code base.

_______________________________________________
wp-hackers mailing list
wp-hackers at lists.automattic.com
http://lists.automattic.com/mailman/listinfo/wp-hackers

_______________________________________________
wp-hackers mailing list
wp-hackers at lists.automattic.com
http://lists.automattic.com/mailman/listinfo/wp-hackers

_______________________________________________
wp-hackers mailing list
wp-hackers at lists.automattic.com
http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list