Pkp-lib: Ensure PHP7 compatibility

Created on 4 Feb 2016  路  13Comments  路  Source: pkp/pkp-lib

There's at least 1 compatibility problem: the String class is now a reserved name. Test and ensure compatibility.

Most helpful comment

Never mind -- I fixed my "problem" by setting the DB driver in config.inc.php to mysqli instead of mysql.

All 13 comments

Things needing doing:

String class renaming:

  • find . -type f -name \*.inc.php -exec sed -i -e "s/String::/PKPString::/g" "{}" ";"
  • Edit imports in:

    • lib/pkp/classes/search/SearchHTMLParser.inc.php

    • lib/pkp/classes/core/PKPApplication.inc.php

  • Rename lib/pkp/classes/core/String.inc.php and adjust class header etc.

New-by-reference is now a syntax error, even if it's in a conditional "if". Remove.

MySQL (not MySQLi) functions removed. Need to use ADODB's MySQLi driver instead.

"split" removed. Suggest "explode" instead. (In ADODB.)

And maybe others... Will raise this on Friday for OJS 2.4.8.

It looks like market share for PHP 7 is currently around 1%, so I'm considering this a non-issue for OJS 2.4.8. Rescheduling for OMP 1.2, and of course for OJS 3.0.

Lots of warnings about function definitions not matching, but those are suppressable and will take some time to get through. Good enough while PHP7 is still nascent in the hosting world.

PHP7 removes mysql_connect(), which means I'm getting this on an OJS installation I'm trying to migrate to Ubuntu 16.04 LTS (which installs PHP7 by default):

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /var/www/vhosts/SERVER/lib/pkp/lib/adodb/drivers/adodb-mysql.inc.php:456

Never mind -- I fixed my "problem" by setting the DB driver in config.inc.php to mysqli instead of mysql.

PHP 7 is eminent. Our server providers are switching completely to PHP 7 in less than an month. We have to either move to a VPS or upgrade OJS to PHP 7. Would prefer the latter. Will there be any help available with updating the OJS 248 code to PHP7?

Hmm, it looks like PHP7 has taken a sudden leap in server share: https://seld.be/notes/php-versions-stats-2017-1-edition

There shouldn't be a massive amount of work required to make OJS 2.4.x PHP7-compatible, but I'll have to take a look.

Indeed. PHP7 is more than half of the market and these stats are from May, so it's going to be even more so about a half a year later, which is now. For us the upgrade to PHP7 is quite urgent, and we would appreciate the expediency in this matter.

@thebiomat, try the following patches:

These were enough to run OJS through its test suite, which includes quite a bit of workflow exercise etc. However, there will be a pile of warnings due to PHP7's increased pickiness (we're still running through these in the OJS 3.x codebase and aren't likely to backport any of that unpleasant work); I also suspect that there will be corners of OJS that'll cause PHP7 to throw errors, but those should be clearly indicated by an error message and we can follow up on them here. I don't expect any of those to require more than tweaks.

I've tested with PHP7.1.0.

If you get the chance to give this a crack, please let me know what your results are. Make sure to clear your template cache (rm cache/t_compile/*.php) to get OJS to recompile all its templates after applying the patches.

That's a really fast response. Thank you very much. We'll give it a try. Since this is a bit over my head, I'll need first ask one of the other folks involved in the server installation.

Could you please explain how to apply the patches?

@thebiomat, you can download a patch file from a git commit URL (like the two above) by adding .diff to the end of the URL. Then, you can apply each patch by following instructions like these:

https://www.lifewire.com/patch-linux-command-unix-command-4097158

See the "how to apply a patch" section of the instructions; use the -p1 flag to the patch tool. The --dry-run option is also useful to test a patch before actually trying to apply it.

Thank you. We'll try it and let you know.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asmecher picture asmecher  路  8Comments

jonasraoni picture jonasraoni  路  6Comments

librariam picture librariam  路  5Comments

asmecher picture asmecher  路  3Comments

asmecher picture asmecher  路  3Comments