Categories
PHP

Upgrading Kohana 3.3.x to PHP 7

PHP 7 should have been released few days ago but is almost here! I am really excited about it but at the same time I was really worried about our old code.

At Open Classifieds we use Kohana 3.3.x (currently 3.3.4), and I started checking for compatibility issues almost a month ago here.

Unluckily Kohana project is dead, branch 3.3.x will not support PHP 7 and there’s no future release for 3.4.x.

If you have some free time you can go ahead and read the first issue I created here and a new issue created here .

Going to the point, if you want to have 3.3.x branch and benefit from PHP 7 advantages it is not complex. I found only 1 big issue and 1 minor 1 in a module.

Classes/Kohana/Kohana/Exception.php

Replace classes/Kohana/Kohana/Exception.php for this one (from a pull not merged).

NOTE: Be aware that if you have extended Exception.php you may get an issue since the functions do not get the parameter type therefore is not backwards compatible.

Kohana/pagination.php

If you use the pagination module (not official)  you will have an issue due to  RFC: Uniform Variable Syntax. The fix again is pretty simple.

Replace file modules/pagination/classes/kohana/pagination.php for this one.

UPDATE APCu

Whatch out with APC, may not work since you need APCu driver. I did a PR to the cache module on KO that fixes it.

WARNING!

Please after replacing the files test your code and run the PHP 7 Compatibility Checker – https://github.com/sstalle/php7cc on your base code to point other issues you may have. You may find some related to userguide (markdown class) and codebench modules but if you do not use them don’t worry.

Some nice resources for PHP7

Image credit to konstantinfo.com