Problems to Anticipate When Upgrading From PHP4 to PHP5, and MySQL4 to MySQL5

A client website just upgraded from PHP4 to PHP5 and MySQL4 to MySQL5 and completely broke. Doing such significant upgrades should have been tested first, but for some reason didn’t happen. I got invited to fix and ran across several problems:

MySQL queries containing some explicit JOINs broke. A simple query like this doesn’t work in MySQL5:

SELECT table1.*, table2.*
FROM table1, table2
LEFT JOIN table3 on table1.col1 = table3.col1

In MySQL 5, the JOIN operator now has a higher precedence than the comma operator, so it interprets the query differently. See this post or the MySQL documentation for more information. The quick fix is to put parenthesis around the tables in the FROM statement, like this:

SELECT table1.*, table2.*
FROM (table1, table2)
LEFT JOIN table3 on table1.col1 = table3.col1

The other significant problem was in the upgrade from PHP4 to PHP5, the XML parsing functions are completely different. PHP 4 used the domxml extentions, where PHP 5 uses a newere DOM extention.

From http://www.php.net/manual/en/ref.domxml.php:

It will, however, never be released with PHP 5, and will only be distributed with PHP 4. If you need DOM XML support with PHP 5 you can use the DOM extension. This domxml extension is not compatible with the DOM extension.

The solution for fixing this, however is quite a bit more complicated. I had to rewrite the XML producing scripts to use the new functionality. Fortunately, the new DOM functionality is pretty straightforward and easier to write, so porting it from one to the other is fairly straightforward, but does require some effort.

MyHosting.com Features are Seriously Lacking

I got my first SourceForge Marketplace job a few days ago for an installation of Awstats for a customer.  I’ve installed Awstats plenty of times and I sometimes have a qwirk or two, but it is generally pretty painless.

Not for an account at MyHosting.com.

Their features are seriously lacking and their security prevention measures too intrusive.   I should have know that I was in for trouble when I realized that they don’t offer any way to create cron jobs.  I ended up having to use a free account with Remote-Cron.com instead, which works, but is not ideal.

The layout of their directories was not very intuitive, and took too much tinkering to figure out.  But the really annoying part is that they limit the file size created by the web server to just 100k.   I was trying to parse a 40 MB of log files for a given month, and awstats would quickly die with an Internal Server Error.   It took a while to finally figure out that it was choking because of the 100k file size limit.

I’ve submitted a ticket to their support asking to increase the file size limit, but will be interested to see if they will allow it.

Windows System Recovery

I rarely write about Windows errors on my blog, but I ran across a weird error on my Windows Laptop the other day that was quite annoying, and a little difficult to fix. Very quickly after the POST, I got an error that said:

 “Windows could not start because the following file is missing or corrupt: C:\WINDOWS\system32\c_1252.nls”

It recommended trying to reinstall Windows using the recovery method. I didn’t have any XP CD’s around, so that wasn’t really an option for me.

I had a Knoppix disc around, so I started that up, and was able to see the partition fine and even mount it.  All of my semi-important files were safe, but I copied them onto another machine just to be sure. When I tried to do a directory listing inside of the windows\system32 directory, I got an I/O error that definitely looked nasty.

After a bit of googling, I came across this page, that has an ISO you can download and boot into a Windows XP Recovery Console.  Once, I was finally at the recovery console, I ran ‘chkdsk /r’ and it appeared to fix a couple problems.  I reran it with ‘chkdsk /r /f’ to be sure that everything was fixed.

After a quick reboot, it stared up Windows without any further issues.