Migrate codeigniter (2.0.3) from php 5.3 to php 5.6 or higher version – conflicts

|
| By Webner

I am working on a client project which is using Codeigniter running on version 2.0.3 and PHP 5.3. I got a requirement from client to upgrade the PHP version from 5.3 to 5.6 or higher. While I tried to upgrade the PHP version I have faced a couple of issues that I am going to describe here. It will be helpful for anyone who needs such upgrade in the production environment to solve these issues.

1. Issue – Only variable references should be returned by reference:

In the codeigniter-> project_root_folder/system_2.0.3/core/Common.php

At line number 257 there is the following statement:

return  $_config[0] =& $config;

To resolve this issue, replace the above line with below lines:

$_config[0] =& $config;

return $_config[0];

There can be multiple locations where you can face above issue.

2. Mysql_result_set not found:

The above error generally occurs due to an invalid database connection. It seems that the database is not accessible. If you face such type of issues check your database connection and its access level from your server machine.

3. Cannot Re-assign auto-global variable _FILES:

This is the most common error that you will face during migration from PHP 5.3 to PHP 5.6.

In most of the code files above variable is used while creating functions. I will demonstrate here by taking one example:

function insert($data, $vector_publishers=array(),$_FILES=array()) {    

// INSERT  CODE BLOCK HERE

}

In the above function declaration $_FILES variable is used and assigning it to an array is causing the issue. To resolve the issue, you should remove all the assignments done with $_FILES variable in the project:

function insert($data, $vector_publishers=array(),$_FILES) {    

// INSERT  CODE BLOCK HERE

}

4) Undefined Constant:

This is the issue that I have faced in most of the files as well. When I checked the files in my code, I found that in each of erroneous file there is a constant defined at the top. I have removed the constant from all those files where I got the issue and then all worked well.

After fixing all the above-mentioned issues Codeignitor works fine on PHP 5.6.

Leave a Reply

Your email address will not be published. Required fields are marked *