[Defender Pro] unexpected 'do' (T_DO), expecting identifier (T_STRING) in php 5.6

Hi, I have a site with wp-defender 2.2.6 + Php 5.6.40-0+deb8u1 and since Feb 17, I am getting this errors while running wp-cron:

PHP Parse error: syntax error, unexpected 'do' (T_DO), expecting identifier (T_STRING) in /var/www/.../wp-content/plugins/wp-defender/app/module/scan/component/scanning.php on line 19

Indeed, there is a do() method in scanning.php. If I change that method and its invocations with i.e. do2() then all works fine.

grep -r "do2()" /var/www/site/wp-content/plugins/wp-defender/
/var/www/site/wp-content/plugins/wp-defender/app/module/scan/component/scanning.php:	public function do2() {
/var/www/site/wp-content/plugins/wp-defender/app/module/scan/controller/rest.php:		$ret      = $scanning->do2();
/var/www/site/wp-content/plugins/wp-defender/app/module/scan/controller/main.php:		$ret      = $scanning->do2();
/var/www/site/wp-content/plugins/wp-defender/app/component/cli.php:			$is_done  = $scanning->do2();
/var/www/site/wp-content/plugins/wp-defender/app/controller/dashboard.php:		$ret      = $scanning->do2();

Regards,

  • Nithin Ramdas
    • Support Wizard

    Hi Ariel Lira ,

    This looks more related to the PHP version you are running. PHP 5.6 has reached its end of life on 2018. Could you please update the PHP version to 7 or greater and then check whether you are able to replicate the same issue? The latest version is 7.4.

    PHP 7 and greater versions are much faster than PHP 5.6 varients. So upgrading to PHP 7 should improve the overall performance of your website.

    Could you please get in touch with your hosting provider and then see how it goes with a version upgrade?

    Looking forward to your response. Have a nice day ahead.

    Regards,
    Nithin

  • Ariel Lira
    • Flash Drive

    Hi Nithin, thanks for your quick response. Yes, it is related with the version of php and the fact a reserved word is used as method name.
    Upgrading to php7 may fix this issue however I can not upgrade it right now, as all the OS will be upgraded in the coming months.
    I patched the code with the quickfix I mentioned before, but it could be nice to have this fixed in upstream, so we get the same level of compatibility between wordpress core (5.6.20+) and wpmudev plugins.
    Thanks again!
    Regards,
    Ariel

  • Nithin Ramdas
    • Support Wizard

    Hi Ariel Lira ,

    WordPress doesn’t recommend PHP version 5.6 anymore. Please check the requirements Page of WordPress:
    https://wordpress.org/about/requirements/

    WordPress recommends version 7.3 or greater for PHP, and we follow these requirements. And since PHP 5.6 has reached EOL there won’t be any security updates or bug fixes for version 5.6. So upgrading PHP would be the ideal workflow here.

    However, I do understand your concern and will make sure to bring this into our developer’s attention to see whether there is any patch that could be implemented in the next release if possible.

    Regards,
    Nithin

  • Ariel Lira
    • Flash Drive

    Hi Nithin, I didn’t see your answer before.
    Just to note I did not say WP recommends PHP 5.6 but just works on it. See this note in https://wordpress.org/about/requirements/

    Note: If you are in a legacy environment where you only have older PHP or MySQL versions, WordPress also works with PHP 5.6.20+ and MySQL 5.0+, but these versions have reached official End Of Life and as such may expose your site to security vulnerabilities.

    Thanks!