Cannot update the database using PHP 5.2

I’m upgrading from OJS 2.4.8 to OJS 2.4.8.1.

I ran the patch command via command line but when I run the upgrade command I get the following error:


[root@bib]# php tools/upgrade.php upgrade

Parse error: syntax error, unexpected T_FUNCTION in /home/ojs/plugins/importexport/crossref/CrossRefExportPlugin.inc.php on line 210


The machine is Centos 5.11 and runs PHP 5.2.17.

The error is seemingly related to PHP 5.2 not interpreting a PHP 5.3 (and above) command. I guess this because the problem is very much like this question I found on StackOverflow.

I can (and will) manually patch this up to fix the problem but, since OJS 2.4.8’s requirements list PHP 4.2 or later, shouldn’t this be fixed in the main code or, at least, made clear that this requires at least PHP 5.3?

The offending line (210) is the first bolded line within the following snippet of code and I suspect that the second bolded line would also break the upgrade:


if ($filter) { $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO'); /* @var $publishedArticleDao PublishedArticleDAO */ if ($filter == CROSSREF_STATUS_NOT_DEPOSITED) { $allArticles = $publishedArticleDao->getBySetting($this->getDepositStatusSettingName(), null, $journal->getId()); $errors = array(); $articles = array_filter($allArticles, function($elem) use($errors){ return $this->canBeExported($elem, $errors); }); } else { $articles = $publishedArticleDao->getBySetting($this->getDepositStatusSettingName(), $filter, $journal->getId()); } } else { $allArticles = $this->getAllPublishedArticles($journal); $errors = array(); $articles = array_filter($allArticles, function($elem) use($errors){ return $this->canBeExported($elem, $errors); }); }

@Kajita, feel free to create an Issue for this in GitHub, and if you code out a solution that works for both PHP after and before 5.3, add that as a pull request.

I opened an issue and a PR is coming soon, s. remove PHP 5.3 code from OJS 2.4.8-1 · Issue #1749 · pkp/pkp-lib · GitHub