Slim application error when exporting users from Statistics [OJS 3.3.0.5]

Working on OJS 3.3.0.5 if we try to export users from Statistics → Users we get a Slim Application Error page with this corresponding error in the server logs:

[Tue May 11 10:50:10.132054 2021] [php7:notice] [pid 7023] [client 172.19.0.3:60836] Slim Application Error:\nType: ParseError\nMessage: syntax error, unexpected '...' (T_ELLIPSIS), expecting ']'\nFile: /var/www/html/ojs3/lib/pkp/classes/user/Report.inc.php\nLine: 67\nTrace: #0 /var/www/html/ojs3/lib/pkp/classes/core/PKPApplication.inc.php(175):

Hi @hilongo,

It seems this is related to the the ellipsis […] token not being properly parsed in Report.inc.php before being sent along to the Slim application. This should be adding additional items to the array.

In order to try and pin down exactly what’s happening, could you provide some additional information about your installation?

  • What version of PHP are you currently using and have you changed it recently?
  • Could you provide the contents of lines 56-71 of /var/www/html/ojs3/lib/pkp/classes/user/Report.inc.php?
  • Are you trying to generate the reports from within OJS or by making an API call directly?

Thanks.

Best,
Erik
PKP Team

Hi @ewhanson !

Thanks for the reply. We’ve recently migrated our installation to a new server and upgraded it from 3.1.2.1 version. So PHP went from 7.2.24 to 7.3.27 (the old server had an Ubuntu 18.04 and the new one has a Debian 10)

The report is being generated from within OJS

as for the lines from Report.inc.php:

/**
* Retrieves the report headings
* @return string[]
*/
private function _getHeadings() : array {
return [
__(‘common.id’),
__(‘user.givenName’),
__(‘user.familyName’),
__(‘user.email’),
__(‘user.phone’),
__(‘common.country’),
__(‘common.mailingAddress’),
__(‘user.dateRegistered’),
__(‘common.updated’),
…array_map(function($userGroup) {
return $userGroup->getLocalizedName();
}, $this->_getUserGroups())
];
}

Thanks in advance

Hi @hilongo,

Thanks for providing the additional information.

It looks like this is a PHP version issue. Using ... as the spread operator in arrays was only added in PHP 7.4 (see original RFC). Upgrading to PHP 7.4 would solve this issue. If this is an option for you, I would recommend upgrading PHP over editing the source code directly, as making changes to the source code will likely create problems upgrading in the future.

Best,
Erik
PKP Team

1 Like

Hi @ewhanson ,

Thanks for the info. I did a quick install of OJS on a test server with PHP 7.4 and the export seems to work there.

We will evaluate the possibility of upgrading the PHP version on our production server.

Best regards!