Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 7.2 compatibility #360

Closed
remocrevo opened this issue Feb 8, 2018 · 6 comments
Closed

PHP 7.2 compatibility #360

remocrevo opened this issue Feb 8, 2018 · 6 comments
Labels
bug This is a bug (not an enhancement)

Comments

@remocrevo
Copy link
Member

When using CORAL with PHP 7.2, a user reported the following error:

Fatal error: Cannot use 'Object' as class name as it is reserved in C:\xampp\htdocs\coral\resources\admin\classes\common\Object.php on line 20

This seems to be caused by PHP 7.2 changing the word "object" to a fully reserved classname, as explained here:

https://wiki.php.net/rfc/object-typehint

This issue can be used to track other PHP 7.2 compatibility requirements, if there are any.

@remocrevo
Copy link
Member Author

  • Rename CORAL class "Object" to something else, everywhere

@PaulPoulain PaulPoulain added the bug This is a bug (not an enhancement) label Feb 28, 2018
@tpwalsh
Copy link

tpwalsh commented Nov 7, 2018

I ran into this while moving from 5.6 to 7.2 due to the former being deprecated. The seems fix is pretty simple, just rename Object to Base_Object. Effectively, the following script will fix the issue(at least according to the testing I've done.)

#!/bin/sh
grep -rl "extends Base_Object" * | xargs sed -i 's/extends Base_Object/extends Base_Object/g'
grep -rl "class Base_Object" * | xargs sed -i 's/class Base_Object/class Base_Object/g'
mv ./auth/admin/classes/common/Object.php ./auth/admin/classes/common/Base_Object.php
mv ./licensing/admin/classes/common/Object.php ./licensing/admin/classes/common/Base_Object.php
mv ./management/admin/classes/common/Object.php ./management/admin/classes/common/Base_Object.php
mv ./organizations/admin/classes/common/Object.php ./organizations/admin/classes/common/Base_Object.php
mv ./usage/admin/classes/common/Object.php ./usage/admin/classes/common/Base_Object.php

@remocrevo
Copy link
Member Author

remocrevo commented Nov 9, 2018

@tpwalsh Thanks for simplifying the solution. However, it looks like your script has a mistake in it. The two "grep" lines search for "Base_Object", but I assume they should search for "Object", right? And similarly, I think the "xargs" commands should reference "Object" in the first half of the regex. That would make the script look like this. Please correct me if I'm wrong.

#!/bin/sh
grep -rl "extends Object" * | xargs sed -i 's/extends Object/extends Base_Object/g'
grep -rl "class Object" * | xargs sed -i 's/class Object/class Base_Object/g'
mv ./auth/admin/classes/common/Object.php ./auth/admin/classes/common/Base_Object.php
mv ./licensing/admin/classes/common/Object.php ./licensing/admin/classes/common/Base_Object.php
mv ./management/admin/classes/common/Object.php ./management/admin/classes/common/Base_Object.php
mv ./organizations/admin/classes/common/Object.php ./organizations/admin/classes/common/Base_Object.php
mv ./usage/admin/classes/common/Object.php ./usage/admin/classes/common/Base_Object.php

@tpwalsh
Copy link

tpwalsh commented Jan 22, 2019

I have no idea why I didn't see the notification of your reply(I'm still new to github I guess). Yes your changes are correct. We've been running this code in production for about a month now with no reported errors.

@zalpany2000
Copy link

any luck with solving this issue without downgrading the PHP version ?

@remocrevo
Copy link
Member Author

@zalpany2000 Yes, you can apply the patch from the following pull request, which should fix CORAL for PHP 7.2:
#541

You can also consider testing the development branch of CORAL, which has other recent fixes but has not been thoroughly tested or released to the public yet:
https://github.com/coral-erm/coral/tree/development

Please email the CORAL User List (coral-user@lists.coral-erm.org) if you have comments or questions about either of those suggestions. You will probably get more response that way, since not many people look at CORAL's GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is a bug (not an enhancement)
Projects
None yet
Development

No branches or pull requests

5 participants