PHP version 4 to version 5 change errors

My hosting provider (1and1) sent me a notice that PHP version 4 support will be discontinued in March 2013. They prompted everyone to try toggling the setting for all website scripts to use PHP version 5, and "see if something breaks" (I am paraphrasing).

I have been putting off upgrading a particular version 4 database and a particular CMS version for a while, and I had a week of vacation. So I said what the heck, and toggled the option for all of website scripts to use PHP version 5 (Global PHP version).

Of course, doing this on a hosting environment with many live websites was a dumb idea. Things seemed to be OK at the first glance, but actually every single one of my websites and their respective software (CMS, Wiki, Forum) were broken. Here is the list:

 

1) A version 4 MySQL database stopped working (Connection error with PHP 5 and MySQL 4). Therefore, if you are using a version 4 MySQL database, you must convert your database first before PHP is upgraded to version 5. I have a series of articles on how to convert an old version 4 MySQL in latin1 encoding into a version 5 MySQL in UTF-8 encoding.

 

2) Conversion of a version 4 MySQL database into a version 5 database gave me a MySQL Error Specified key was too long.

 

3) Conversion from InnoDB to MyISAM gave me a FULLTEXT error (I "fixed" this by rolling back my version 5 MySQL database to the MyISAM engine). I will need to fix this in the future and upgrade to InnoDB, which is the default for MySQL v5.5+.

 

4) PHP E_STRICT error notices started appearing on all of my websites. This is due to the fact that PHP now considers E_STRICT notices as "warnings". You will need to change either the code which generates this error (as you will see below, often requiring manual tweaks rather than useless upgrades), with a PHP.INI change (you will not have access to this on shared hosting, except for a folder-by-folder basis), or with an .htaccess change (so far I was unable to get this to work).

 

5) MediaWiki failed with:

Strict Standards: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EST/-5.0/no DST' instead in /*/htdocs/*/includes/Setup.php on line 206

Amazingly, upgrading to MediaWiki 1.20.* was of no help, and browsing MediaWiki forums told me that developers are aware of this issue, but no upgrades or patches exist yet to correct this.

Rather than ignoring this error, I manually modified the Setup.php file

/**
* Set up the timezone, suppressing the pseudo-security warning in PHP 5.1+
* that happens whenever you use a date function without the timezone being
* explicitly set. Inspired by phpMyAdmin's treatment of the problem.
*/
if ( is_null( $wgLocaltimezone) ) {
wfSuppressWarnings();
$wgLocaltimezone = date_default_timezone_get();
wfRestoreWarnings();
}

With

$wgLocaltimezone = 'America/New_York';

You will need to modify this according to your timezone of your server.

By the way, notice that the commented block of code alludes that this would fix PHP E_STRICT warning. WRONG!

 

6) PHPBB3 version 3.0.8 failed. It would no longer allow me to login. Errors were generated when attempting to view a post:

Strict Standards: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EST/-5.0/no DST' instead in /*/htdocs/*/viewtopic.php on line 988

Strict Standards: getdate(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EST/-5.0/no DST' instead in /*/htdocs/forum/viewtopic.php on line 988
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4505: Cannot modify header information - headers already sent by (output started at /viewtopic.php:988)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4507: Cannot modify header information - headers already sent by (output started at /viewtopic.php:988)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4508: Cannot modify header information - headers already sent by (output started at /viewtopic.php:988)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4509: Cannot modify header information - headers already sent by (output started at /viewtopic.php:988)

 

And when attempting to login in, even as an administrator:

Strict Standards: Non-static method utf_normalizer::nfkc() should not be called statically in /*/htdocs/*/includes/utf/utf_tools.php on line 1663
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1024: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1663)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1024: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1663)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1024: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1663)

Warning: Cannot modify header information - headers already sent by (output started at /*/htdocs/*/includes/utf/utf_tools.php:1663) in /*/htdocs/*/includes/functions.php on line 4505

Warning: Cannot modify header information - headers already sent by (output started at /*/htdocs/*/includes/utf/utf_tools.php:1663) in /*/htdocs/*/includes/functions.php on line 4507

Warning: Cannot modify header information - headers already sent by (output started at /*/htdocs/*/includes/utf/utf_tools.php:1663) in /*/htdocs/*/includes/functions.php on line 4508

Warning: Cannot modify header information - headers already sent by (output started at /*/htdocs/*/includes/utf/utf_tools.php:1663) in /*/htdocs/*/includes/functions.php on line 4509

 

And again, PHPBB3 support forum instructions were somewhat confusing about how exactly to repair a 3.0.8 installation. However, an upgrade to 3.0.11 went smoothly and has eliminated all of these errors.



˅˅˅ Additional valuable information is available at one of the links below: ˅˅˅

 

Did you like the article? Let Google Search know by clicking this button: . Please link to content that you find useful on this website on your own website, forum or blog! You can also comment on this page below, or contact me to ask a question or suggest a topic for me to research. There is a user-editable Wiki available on my website, as well as a Forum that you can contribute to. Site Map.

Page last modified 06-Jan-13 20:07:06 EST
Comments on this page:


Add a comment to this page
Comment Title:
Your Name:
Your Email Address:
Notify me of new comments to this item:
Additional Comments:
This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)