PHP Fatal error: Uncaught Error: Call to a member function getId() on null in /classes/oai/ojs/OAIDAO.inc.php:185

When I enable OJS access distribution, the OAI returns an HTTP ERROR 500 error.
Checking erro_log, I get this.

[Sat Jun 18 17:07:53.750733 2022] [php7:error] [pid 25697] [client 181.66.195.133:42979] PHP Fatal error: Uncaught Error: Call to a member function getId() on null in /var/www/ojs_university/classes/oai/ojs/OAIDAO.inc.php:185\nStack trace:\n#0 /var/www/ojs_university/lib/pkp/classes/oai/PKPOAIDAO.inc.php(239): OAIDAO->setOAIData()\n#1 /var/www/ojs_university/lib/pkp/classes/oai/PKPOAIDAO.inc.php(203): PKPOAIDAO->_doCommonOAIFromRowOperations()\n#2 /var/www/ojs_university/lib/pkp/classes/oai/PKPOAIDAO.inc.php(132): PKPOAIDAO->_returnRecordFromRow()\n#3 /var/www/ojs_university/classes/oai/ojs/JournalOAI.inc.php(178): PKPOAIDAO->getRecords()\n#4 /var/www/ojs_university/lib/pkp/classes/oai/OAI.inc.php(507): JournalOAI->records()\n#5 /var/www/ojs_university/lib/pkp/classes/oai/OAI.inc.php(85): OAI->ListRecords()\n#6 /var/www/ojs_university/pages/oai/OAIHandler.inc.php(39): OAI->execute()\n#7 /var/www/ojs_university/lib/pkp/classes/core/PKPRouter.inc.php(395): OAIHandler->index()\n#8 /var/www/ojs_university/lib/pkp/classes/core/PKPPageRouter.inc.php(246): PKPRouter->_authorizeInitializeAndCallRequest()\n#9 /var/www/ojs_university in /var/www/ojs_university/classes/oai/ojs/OAIDAO.inc.php on line 185

The ojs version is OJS 3.3.0.9

Hello,
I am also getting the same error, has anyone found a solution?
OJS: 3.4.0.6
OS: Linux
Database server version: 10.6.18-MariaDB-0ubuntu0.22.04.1

[php:error] [pid 37808:tid 37808] [client xxx.xxx.xxx.xxx:26964] PHP Fatal error: Uncaught Error: Call to a member function getId() on null in classes/oai/ojs/OAIDAO.php:225\nStack trace:\n#0 lib/pkp/classes/oai/PKPOAIDAO.php(261): APP\oai\ojs\OAIDAO->setOAIData()\n#1 lib/pkp/classes/oai/PKPOAIDAO.php(219): PKP\oai\PKPOAIDAO->_doCommonOAIFromRowOperations()\n#2 lib/pkp/classes/oai/PKPOAIDAO.php(153): PKP\oai\PKPOAIDAO->_returnRecordFromRow()\n#3 classes/oai/ojs/JournalOAI.php(195): PKP\oai\PKPOAIDAO->getRecords()\n#4 lib/pkp/classes/oai/OAI.php(5425

Thanks
Nason

Hi @Nason_Bimbe,

It looks like you have a data error. Try the following database query:

SELECT s.* FROM submissions s LEFT JOIN publications p ON (s.current_publication_id = p.publication_id) WHERE p.publication_id IS NULL;

If you have any results, then it indicates that you have a submission without a publication. You should probably delete the submissions entry. (Make sure to take a backup before working with the database directly!)

Regards,
Alec Smecher
Public Knowledge Project Team

Thank you @asmecher

I will give it a go and feedback

Regards
Nason

Hi @asmecher

I have run the query and this is the result. No records found.

MariaDB [xxxx]> SELECT s.* FROM submissions s LEFT JOIN publications p ON (s.current_publication_id = p.publication_id) WHERE p.publication_id IS NULL;
Empty set (0.072 sec)

Hi @Nason_Bimbe,

Hmm, I don’t see another cause at a glance. Is it possible that the error message was received with your database in a different state that has since been resolved? Or do you see this error message frequently (e.g. every time you access the OAI interface)?

Regards,
Alec Smecher
Public Knowledge Project Team

This topic was automatically closed after 13 days. New replies are no longer allowed.