0

I get this error in my cron.log and as a result no emails seem to work:

PHP Parse error: syntax error, unexpected '[' in /var/www/vhosts/gsequestrian.co.uk/httpdocs/app/code/community/Ebizmarts/Mandrill/Model/Email/Queue.php on line 35

Link to code: https://www.dropbox.com/s/ecnwecmi8pwx9be/Queue.php?dl=0

Section starting line 35:

$mandrill = [
                    'subject' => $parameters->getSubject(),
                    'to' => [],
                    'from_email' => $parameters->getFromEmail(),
                    'from_name' => $parameters->getFromName(),
                    'headers' => $mailer->getHeaders(),
                    'html' => ($parameters->getIsPlain() ? "" : $message->getMessageBody()),
                    'text' => ($parameters->getIsPlain() ? $message->getMessageBody() : ""),
                ];
  • What version of PHP are you on? Using [] is only supported in PHP 5.4+ – Paul Mar 21 '16 at 12:23
  • I'm using PHP version 5.5.33. – Rob Hannaford Mar 21 '16 at 13:19
1

It's a syntax error because you are running an outdated PHP version which does not support short array notation. This version of the Mandrill extension obviously does not support PHP 5.3

The only reasonable solution is to update to PHP 5.5 or 5.6, depending on your Magento version. They added 5.6 support with Magento 1.9.1

  • I'm using PHP 5.5.33. – Rob Hannaford Mar 21 '16 at 13:19
  • Your cronjob does not. Many hosters run a different PHP version on the command line. – Fabian Schmengler Mar 21 '16 at 13:23
  • Similar problem: magento.stackexchange.com/questions/61628/… – Fabian Schmengler Mar 21 '16 at 13:26
  • Ok as per that link can I change my CRON command so that it knows to use 5.5? THis is what I have currently as the command: /opt/plesk/php/5.5/bin/php -f /var/www/vhosts/gsequestrian.co.uk/httpdocs/cron.php >> /var/www/vhosts/gsequestrian.co.uk/httpdocs/var/log/cron.log 2>&1 – Rob Hannaford Mar 21 '16 at 13:33
  • 1
    That looks like it should use PHP 5.5 but because the mode parameter is missing, it will probably trigger cron.sh which in turn runs "php" without specified path. Change the command to /opt/plesk/php/5.5/bin/php -f /var/www/vhosts/gsequestrian.co.uk/httpdocs/cron.php -- -mdefault >> /var/www/vhosts/gsequestrian.co.uk/httpdocs/var/log/cron.log 2>&1 to prevent this – Fabian Schmengler Mar 21 '16 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.