Submission without publication in disabled journal, makes rebuildSearchIndex.php crash

Describe the issue or problem
the tools/rebuildSearchIndex.php crashes on line 38,
PHP Fatal error: Uncaught Error: Call to a member function getData() on null in /usr/local/ojs/classes/search/ArticleSearchIndex.inc.php:38
and I found this related post

I did the select to find out if I have any submissions without publications and I did find one. It belongs to a journal that is not active anymore.

The result of select:
submission_id: 53
context_id: 4
date_submitted: 2007-01-15 17:51:44
last_modified: 2007-12-16 13:40:54
status: 3
submission_progress: 0
stage_id: 4
current_publication_id: 51
date_last_activity: 2007-12-16 13:40:54
work_type: 0
locale: en_US

Can the whole journal + contents be deleted to just get rid of it? Or will we have to enable the journal to be able to try and remove the submission in the web interface?

Version of OJS is 3.3.0.15

Hi @mirkh,

It’s entirely up to you whether you delete the entire journal, or just the submissions without publications. If the journal has an important scholarly record to preserve, then I would suggest deleting just the problem submissions.

The quickest/easiest way to do that, if you have access to the command line, is probably to use tools/deleteSubmissions.php. I haven’t tried it specifically on submissions without publications, but that’s where I’d start.

Make a backup before you start taking drastic actions like deleting journals or submissions en masse!

Regards,
Alec Smecher
Public Knowledge Project Team

Thanks @asmecher, I had forgotten about the deleteSubmissions.php script. The journal that created the submission without publication has migrated to another installation and to make it even more secure, I’m doing this on a copy of the production right now.

I wanted to see if I was able to rebuild the search index, as we decided we want to truncate the three index tables to speed up our next upgrade.
deleteSubmissions.php for one submission_id (the one found by the select above) failed with

PHP Fatal error: Uncaught Error: Call to a member function getStatus() on null in /usr/local/ojs/lib/pkp/classes/submission/reviewRound/ReviewRoundDAO.inc.php:238

Hi @mirkh,

Hmm, it looks like that’s caused by additional missing data – in this case, review rounds.

If the journal has already been migrated elsewhere, then I would lean towards removing the journal entirely. But if you have a journal with partial data in it, you might run into problems with that too, where even the deletion process expects the data to have a level of integrity.

The good news is that upgrading to 3.4 and 3.5 will add referential integrity checks so that this kind of partial data won’t be possible in the future. The process of upgrading will clean up data where that’s possible to do without any particular knowledge of the journal, but OJS will stop short of deleting entire submissions and in all likelihood you’ll be prompted to do some cleanup when you try to run the upgrade script.

Long story short, an eventual plan to upgrade will help clean up your data, but you might be in a situation already where some manual actions in the database will be necessary. I would start (after taking a good backup!) by removing the entries in submissions and journals related to the journal that’s been migrated. It’s entirely possible that just doing that will resolve the problem with the search index rebuild, and I believe the upgrade process to 3.4 and above (when you’re ready to tackle it) will take that as sufficient cause to remove anything left related to the missing submissions.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher, thanks for your reply. It is great that there are more integrity checks in the newer versions.
I did some steps, (backup first)

  • removed all submissions that belonged to the migrated journal
  • truncated the search index tables again
  • ran the rebuildSearchIndex script

Unfortunately it crashed on the same line, and it’s trying to index a journal that is enabled. Line 38 in our OJS version of classes/search/ArticleSearchIndex.inc.php is
foreach ($publication->getData(‘authors’) as $author) {
and I guess there is something wrong with the authors table then?

PHP Fatal error: Uncaught Error: Call to a member function getData() on null in /usr/local/ojs/classes/search/ArticleSearchIndex.inc.php:38
Stack trace:
#0 /usr/local/ojs/classes/search/ArticleSearchIndex.inc.php(280): ArticleSearchIndex->submissionMetadataChanged()

Finally I did a new test to rebuild the index where I disabled the journal where the error occurred to see if it would skip it, but it failed in the same place on the same journal.

I might not be understanding the db design, but if I turn around the search for submissions/publications to

select p.* from publications p left join submissions s on (s.current_publication_id = p.publication_id) where s.current_publication_id IS
NULL;
I get 1048 rows where the submission_id in publications don’t exist in submissions.

Edited to add: I was just reminded that the journal that crashes the rebuild search index had a lot of content imported. Are there any scripts to check if a certain journal’s data is “correct”?

Hi @mirkh,

I suspect failed imports have a lot to with this. An entry in submissions that doesn’t have a corresponding entry in publications (via current_publication_id) won’t be worth much – it won’t have a title, abstract, set of contributors, etc.

Again, after taking a backup, I’d recommend removing any entries in submissions that don’t have matching entries in publications.

Regards,
Alec Smecher
Public Knowledge Project Team

Thanks again, @asmecher , and thanks for all these replies, it helped.

We found a few imported submissions in the problematic journal where current_publication_id pointed to a real publication row — but one that belonged to a different submission (eg current_publication_id = 1). These submissions had no publications of their own, no metadata, no authors, but were marked as complete.

I have removed those submissions and now the rebuild search index script does not fail on that journal anymore. So it will feel better to truncate the search index tables, knowing that I now can rebuild their content. :smiley:

Hi @mirkh,

Very strange – I’ve never seen that situation before! Please let me know if you’re able to determine the conditions that caused it – I would guess it’s something to do with the import. Nonetheless, I’m glad to hear it’s resolved.

Thanks,
Alec Smecher
Public Knowledge Project Team

It is an old installation we have, where the latest created journal is number 89. The import for the journal with the problems was made already in 2023, so I don’t think I’ll try and find out.

Have a good weekend! Thanks for your help.

1 Like

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