Suitecrm: PHP4 style constructors should be already removed since 7.8

Created on 20 Dec 2017  路  5Comments  路  Source: salesagility/SuiteCRM

Lot of code on SuiteCRM has constructors of PHP4 style. Since PHP 7.0 triggers deprecation messages everywhere.

Issue

Most of this code points out that it should be removed on version 7.8, SuiteCRM is on 7.9 and the code still there. When code is executed with PHP4 constructors, warnings message shows on the screen. Sometimes, it mess up with the markup.

Expected Behavior

No deprecations messages.

Actual Behavior

Screen and logs files are filled up with messages as Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP;

Possible Fix

The error level could be adjusted, but defeat the purpose of fixing this problems on time before they are completely removed and become errors.

On my IDE I can run this regular expression on the root folder to identify all files that contains classes and functions with the same name (PHP4 constructors):
class\s+([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[\s\{\n]{1}[[:print:]\n\r\t]*function\s+\1\s*\(

It produces some false matches, but they are very little.

Steps to Reproduce

  1. As sample of this issue, look at /modules/vCals/vCal.php
  2. Class name is vCal on line 45
  3. It has already the correct constructor at line 73
  4. The old PHP4 constructor still there at line 83, and includes the message that should be removed on version 7.8

Context

Yes, we have enable the deprecation error level because we must get rid of all obsolete code. Our primary goal is assuring that SuiteCRM will work on PHP 7.1. Secondary goal is to move to PHP 7.2 (production) as soon as possible due that 7.1 has major bug with TS version on Windows and will not be fixed. At the moment we are running 7.1 NTS with FastCGI, but we are not happy with the performance. Before we could but move on, all these deprecations need to be fixed.

I could work on a pull request with all the required changes, however, it will be a big one as I can count approximate around 500 files will need changes. Then I have to backtrace making sure there are not calls of those classes using the PHP4 constructor or static calls.

Your Environment

  • SuiteCRM Version used: 7.8.8
  • Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Irrelevant
  • Environment name and version (e.g. MySQL, PHP 7): Apache 2.4.29/PHP 7.1.12 NTS FastCGI/MySQL 5.7.20 - all x64 version.
  • Operating System and version (e.g Ubuntu 16.04): Windows Server 2016
Moderate Fix Proposed Bug

All 5 comments

@Dillon-Brown has this been fixed? I think I saw a commit recently that removed the deprecated constructors.

Yeah I have a PR for it: #6750. Still need to take a look at the failing Travis though.

Great to see some action here. I thought this issue was ignored.

So far we have put our CRM server on ice, so it doesn't change from PHP 7.1. On the last year we have optimized the FastCGI to give acceptable performance, but it requires that we dedicate the double of memory.

Looking forward that this is completed, so we could resume our testing on PHP 7.2 and now 7.3.

6750 should now hopefully fix all the PHP4 style constructors + conflicts resolved + passing Travis. Please let me know if you spot any my Regex missed though, Thanks!

Ok that is great news. At the moment, we were stuck on old version 7.8.5 because the upgrade to a recent version failed (all modules the Edit layout just showed the overview panel). I have to revert the upgrade.
I have to dedicate some time to try to upgrade on smaller stages instead all the way to the latest.
I will report back if I find any issue. Ahead of time thanks for the hard work put to clean up this code!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pgorod picture pgorod  路  3Comments

Mausino picture Mausino  路  3Comments

ajprouty87 picture ajprouty87  路  3Comments

sasha2002 picture sasha2002  路  3Comments

likhobory picture likhobory  路  3Comments