Asa2_Cron_Ratings produces parse error: syntax error, unexpected ‚{‚

Problem

The following error occurs when executing an ASA2 cronjob:

Parse error: syntax error, unexpected '{' in /****/blog/wp-content/plugins/amazon-simple-affiliate/lib/IfwAsa2/Wp/Plugin/Cli/Executables/script.php on line 18

or

Return value of Asa2\Api\AmazonPa\Operation\AbstractOperation::initEventGroup() must be an instance of Asa2\Api\AmazonPa\Operation\void, none returned

Solution

This is probably because you are running the cronjob with an outdated PHP version which does not support the code in the cronjob script. Check out the currently supported PHP versions.

With some webhosters the standard command „php“ executes an outdated version and there is a special command for each version, e.g. „php7“ or „php73„. Which version the command „php“ uses, you can see by executing „php -v„. If this results in a version less than the currently supported (see the link above), please ask your webhoster how you can run PHP scripts on the shell with a current version.

For example, if there is a „php74“ command on your server that allows you to run PHP version 7.4 on the shell, you can tell the ASA2 cronjob that it should use this command with the „php“ option, like this:

bash script.sh Asa2_Module_Repo_Cron_Refresh --limit=10 --php=php74

Check the manual page about the php option for more details.

 

Timo