ojsde / dnb

OJS plugin that exports full texts and metadata to the Deutsche Nationalbibliothek (DNB)
GNU General Public License v2.0
3 stars 3 forks source link

Undefined constant "SCHEDULED_TASK_EXECUTION_LOG_DIR" #20

Closed kirchnerf closed 6 months ago

kirchnerf commented 6 months ago

If you activate automaticDeposit in the backend, the following error appears in the Apache web server log:

PHP Fatal error: Uncaught Error: Undefined constant "SCHEDULED_TASK_EXECUTION_LOG_DIR" in /ojs/plugins/importexport/dnb/DNBExportPlugin.inc.php:384\nStack trace:\n#0 /ojs/lib/pkp/pages/management/PKPToolsHandler.inc.php(94): DNBExportPlugin->display()\n#1 /ojs/lib/pkp/classes/core/PKPRouter.inc.php(397): PKPToolsHandler->importexport()\n#2 /ojs/lib/pkp/classes/core/PKPPageRouter.inc.php(246): PKPRouter->_authorizeInitializeAndCallRequest()\n#3 /ojs/lib/pkp/classes/core/Dispatcher.inc.php(144): PKPPageRouter->route()\n#4 /ojs/lib/pkp/classes/core/PKPApplication.inc.php(360): Dispatcher->dispatch()\n#5 /ojs/index.php(68): PKPApplication->execute()\n#6 {main}\n thrown in /ojs/plugins/importexport/dnb/DNBExportPlugin.inc.php on line 384, referer: https://ojs.example.org/myjournal/management/settings/website

OJS version: 3.3.0.16 DNB plugin version: 1.5.0 The Acron plugin is deactivated because we use cronjobs.

ronste commented 6 months ago

Hi @kirchnerf ,

the missing constant is defined ScheduledTaskHelper.inc.php and should be available without additional imports and with Acron disabled. At least it is on our systems.

Does it work for you if the Acron plugin is enabled?

You can try to add the following line to top of the file plugins/importexport/dnb/DNBExportPlugin.inc.php:

import('lib.pkp.classes.scheduledTask.ScheduledTaskHelper');

kirchnerf commented 6 months ago

If I activate the Acron plugin it works, if it is deactivated it only works if I explicitly import the ScheduledTaskHelper. As a supplement: we use PHP 8 and Apache with mod_php

ronste commented 6 months ago

If I activate the Acron plugin it works, if it is deactivated it only works if I explicitly import the ScheduledTaskHelper. As a supplement: we use PHP 8 and Apache with mod_php

Ok, thanks for the info. To be on the safe side I will just add the import to the repo.

kirchnerf commented 6 months ago

My (naive) assumption: According to the PHP documentation, define defines a constant at runtime. Since mod_php gives each request a new/own PHP OJS environment, the ScheduledTaskHelper is never called if the Acron plugin is missing. This means that its constants are never defined. In addition, when executing the ScheduledTasks via the crontab, the PHP CLI is used, which means that the constants of the ScheduledTaskHelper are probably also not available for web calls. The best solution seems to be to always import the ScheduledTaskHelper explicitly, as you suggested.

Thanks for your quick answers and the fix!