cron job error

Hello friends

Today I have installed SuiteCRM, everything works perfect, but when you run cron.php the following error appears:

PHP Parse error: syntax error, unexpected ‘class’ (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or ‘{’ or ‘$’ in /var/www/vhosts/domain/httpdocs/modules/ACL/ACLController.php on line 81

Somebody could help me? Beforehand thank you very much.

Hello,

Can you specify which version of SuiteCRM are you using along with PHP version?
I believe if you have PHP version greater then 5.5. It will work.
For Error
You may go through this
http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.class.class

For SuiteCRM Compatibility Matrix:
https://docs.suitecrm.com/admin/compatibility-matrix/

Thank you urdhvatech for your answer.

I detail technical data of the installation:
PHP 7.2.11
MYSQL 5.5.60
SUITECRM 7.10.9

ACLController.php line 81 image:

thanks!!

Hi there,

I am having the exact same issue. None of my scheduled tasks are able to run. So I tried running the cron job manually and I get the following error:

PHP Parse error: syntax error, unexpected ‘class’ (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or ‘{’ or ‘$’ in /var/www/vhosts/xxDomainNamexx.com/crm.xxDomainNamexx.com/modules/ACL/ACLController.php on line 81

PHP version: 7.1.27
SuiteCRM: 7.11.2
MYSQL: 5.5.60
Server: Linux w/ Plesk

Where did you get that PHP version number from? If it was from the command line (“php -v”) please check inside SuiteCRM, Admin / Daignostics / phpinfo, to see if it is the same.

Hey pgr,

I ran the SuiteCRM Diagnostics tool (admin > Diagnostics tool) and compared them with sever’s PHP installed setting. They both are the same. I am using Plesk to manage my server. It currently has PHP 7.1.27 installed and running on it.

You can try changing this line

https://github.com/salesagility/SuiteCRM/blob/master/modules/ACL/ACLController.php#L81

to this

        if ($category === get_class(new AOS_Products_Quotes)) {

but think of this as a temporary test (tell me if it works). I don’t fully know the consequences of this change (it could break all security permissions handling) so after the test you should probably change it back unless this is just a test system.

I made the change, now I get the following error. It is a test system so I don’t mind the code change.

[code]

Task “cd /var/www/vhosts/xxDomainNamexx.com/httpdocs/crm; php -f cron.php” completed with error in 0 seconds, output:

PHP Parse error: syntax error, unexpected ‘class’ (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or ‘{’ or ‘$’ in /var/www/vhosts/xxDomainNamexx.com/httpdocs/crm/modules/ACL/ACLController.php on line 83

[/code

I made the change, now I get the following error. It is a test system so I don’t mind the code change.



Task "cd /var/www/vhosts/xxDomainNamexx.com/httpdocs/crm; php -f cron.php" completed with error in 0 seconds, output:

PHP Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /var/www/vhosts/xxDomainNamexx.com/httpdocs/crm/modules/ACL/ACLController.php on line 83

Ah sorry I didn’t see that the same construct was used in the following lines. You just have to make the same replacement in all of them so that block turns into:


        if ($category === get_class(new AOS_Products_Quotes)) {
            return (
                ACLAction::userHasAccess($current_user->id, get_class(new AOS_Quotes), $action, $type, $is_owner, $in_group)
                || ACLAction::userHasAccess($current_user->id, get_class(new AOS_Invoices), $action, $type, $is_owner, $in_group)
                || ACLAction::userHasAccess($current_user->id, get_class(new AOS_Contracts), $action, $type, $is_owner, $in_group)
            );
        }

Could it be some type of PHP comparability issue? I made the change. Now I am getting the following error.


Task "cd /var/www/vhosts/xxDomainNamexx.com/httpdocs/crm; php -f cron.php" completed with error in 1 seconds, output:

PHP Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /var/www/vhosts/xxDomainNamexx.com/httpdocs/crm/include/Imap/ImapHandlerFactory.php on line 201

Update: With the code changes on lines 81 to 87 of “/modules/ACL/ACLController.php”, I get the above mentioned error only 30/40% of the time. The other times is does not show the error I get the following message. In any case, the scheduler doesn’t seem to be running correctly.

Task "cd /var/www/vhosts/myhousenj.com/httpdocs/crm; php -f cron.php" successfully completed in 0 seconds.

Is there anything else I should try?

  1. If you type “php -v” on the command-line, which version do you get? (PHP CLI, which is used for cron, might be different from the one inside your web server)

  2. Can you turn off display_errors in both your php.ini’s? (web server + CLI)

My server was running the command-line Cron Jobs with PHP 5.4. I was able to correct it, and now I do not receive any more errors! It looks like everything is working now =)

Thank you for your help!!!

Same here. Seems the CLI and the webserver like to use different versions of PHP unless you tell them not to. Here are a few points that helped me solve it:

To test your cron.php at the CLI manually:

cd /home/username/public_html/suitecrm; php -c /home/username/public_html/suitecrm/php.ini -f cron.php > /dev/null 2>&1

would send the results of this command into the ether of /dev/null, so we can use:

cd /home/username/public_html/suitecrm; php -c /home/username/public_html/suitecrm/php.ini -f cron.php

I was getting:


Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home/username/public_html/suitecrm/modules/ACL/ACLController.php on line 81

Check your PHP version in suiteCRM directory install:

php --version
PHP 5.4.45 (cli) (built: Apr 17 2017 15:59:08) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v10.2.4, Copyright (c) 2002-2018, by ionCube Ltd. with Zend Guard Loader v3.3, Copyright (c) 1998-2013, by Zend Technologies

shows me that PHP CLI version is at 5.4.x not the 7.1 that makes SuiteCRM so happy.

the way to change CLI PHP version will vary for your hosting, but these directions helped me:
https://stackoverflow.com/questions/39643805/need-to-run-composer-update-on-ssh-on-hostgator-but-php-v-to-low

after this change to ~/.bashrc, I’m not sure it was needed but I force the cron job to use the php.ini for my SuiteCRM install:

php -c /home/username/public_html/suitecrm/php.ini -f /home/username/public_html/suitecrm/cron.php > /dev/null 2>&1

less errors in error_log and now the cron will do it’s thing.

I had a similar issue. Even though my host interface indicated that I was running PHP 7.1 on my site, the cron job was running at PHP 5.X. This may have had something to do with the hosting environment/control panel. I use Plesk control panel. The hosting service was able to verify the issue, but not able to correct it. The only way around it, was to force the script to run PHP 7.1. So I wrote the following script…

Here is the syntax:

##PHP 7.x server folder location## -q ##cron.php server location## > dev/null 2>&1

Here is my script:

/opt/plesk/php/7.1/bin/php -q /var/www/vhosts/MyAwesomeSite.com/cron.php > /dev/null 2>&1