Upgrading from 2.4.8-3 to 3.1.1-4: Call to a member function getFileId() on null in lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php

Hello everyone,
we came to another issue during our upgrade process from OJS 2.4.8-3 to 3.1.1-4:

PHP Fatal error: Call to a member function getFileId() on null in lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 1065

Hi @GustavoTonini

And when exactly did this error occurred i.e. at which upgrade step (that you see when upgrading via command line)?


Hey @bozana,
the error appears after the start of the step [code: Installer Installer::provideSupplementaryFilesForReview]

Hi @GustavoTonini

Maybe it is the same problem as described here: Upgrade provideSupplementaryFilesForReview fails with "Invalid file!" · Issue #4287 · pkp/pkp-lib · GitHub
I.e. maybe there are some files/entries in your DB table article_supplementary_files that are not in the table article_files.
Could you maybe run this SQL on your OJS 2 DB to test it:

SELECT a.journal_id, sf.* FROM article_supplementary_files sf, articles a WHERE a.article_id = sf.article_id AND sf.file_id <> 0 AND sf.show_reviewers = 1 AND sf.remote_url IS NULL and sf.file_id not in (select f.file_id from article_files f);

Those entries should then be removed from the DB table article_supplementary_files. Please make a full backup before doing any changes in your DB.

Then you would need to start the upgrade anew, using the clean backup of your OJS 2 installation. Every time an upgrade is run, it has to run on a clean backup (and NOT on the DB, the code and the files that already went through an unsuccessful upgrade).

You can report here how does your result from the SQL above look look, then we can see further…


Hi @bozana, this query doesn’t return records on my original ojs2 database. I also deleted some records with file_id=0 but the error persists.

Hi @GustavoTonini

Could you maybe test these two SQLs too:
SELECT sf.* FROM article_supplementary_files sf WHERE sf.show_reviewers = 1
SELECT sf.* FROM article_supplementary_files sf WHERE sf.file_id <> 0 AND sf.remote_url IS NULL AND sf.file_id not in (select f.file_id from article_files f)
and provide the results?


the second query doesn’t return records.
The results of the first one are at https://arquivos.ufsc.br/f/1fcd9664da/?raw=1

Thanks for your assistance.

Hi @GustavoTonini

I downloaded the file, so you can remove it…
If I see it correctly, the function _castToGenre (where the error occurs) is called in the function insertObject in PKPSubmissionFileDAO.inc.php. The insertObject is called when the supp file is copied for the review (stage) here ojs/Upgrade.inc.php at ojs-3_1_1-4 · pkp/ojs · GitHub → pkp-lib/SubmissionFileManager.inc.php at ojs-3_1_1-4 · pkp/pkp-lib · GitHub.
But I have no idea why this could be :-
Would it maybe be possible for you to debug it, to print some variables out? – E.g. to see how the variables submissionFile, sourceFile, targetDaoDelegate ad insertedFile look like here pkp-lib/PKPSubmissionFileDAO.inc.php at ojs-3_1_1-4 · pkp/pkp-lib · GitHub.
You could for example create a file debug.txt (writable for the web user) in your OJS folder and print the output there, e.g. you could put something like this on that line 311 in PKPSubmissionFileDAO.inc.php:

$file = 'debug.txt';
$current = file_get_contents($file);
$current .= print_r("++++ submissionFile: ++++\n", true);
$current .= print_r($submissionFile, true);
$current .= print_r("++++ sourceFile: ++++\n", true);
$current .= print_r($sourceFile, true);
$current .= print_r("++++ targetDaoDelegate: ++++\n", true);
$current .= print_r($targetDaoDelegate, true);
$current .= print_r("++++ insertedFile: ++++\n", true);
$current .= print_r($insertedFile, true);
file_put_contents($file, $current);

Or use the similar code to make even more outputs throughout those functions…
Then run the upgrade again (on a clean OJS 2 backup) and see what is then in the file debug.txt… especially the last entries…


Hi @GustavoTonini

also if you see some other relevant warnings during the upgrade process, that are displayed on the CLI, e.g. PHP Warning: copy(files/…): failed to open stream: No such file or directory in /lib/pkp/classes/file/FileManager.inc.php on line …, please report them…


Hi @GustavoTonini

Maybe you could also try these two SQLs:
SELECT ra.review_id, ra.submission_id, ra.reviewer_file_id FROM review_assignments ra WHERE ra.reviewer_file_id IS NOT NULL AND ra.reviewer_file_id NOT IN (SELECT file_id FROM article_files)
to see if a reviewer file is missing in the article_files table.

SELECT DISTINCT ra.submission_id, ra.round, af.revision FROM review_assignments ra, article_files af, articles a WHERE (ra.submission_id, ra.round) NOT IN (SELECT rr.submission_id, rr.round FROM review_rounds rr) AND a.article_id = ra.submission_id AND af.article_id = a.article_id AND af.file_id = a.review_file_id AND af.round = ra.round
to see if eventually a review round entry is missing in the DB.

EDIT 1: I do not think this is a problem in your case, but just to be sure: see if all your articles have a section_id entry in the DB table articles. Also if all sections exists:

SELECT a.article_id FROM articles a LEFT JOIN sections s ON (a.section_id = s.section_id) WHERE s.section_id IS NULL

EDIT 2: What you could also do anyway is to investigate and eventually repair those files that have file_id = 0 but also remote_url = NULL. In general remote files (supp files and galleys) will have file_id = 0 but there should be a remote_url there.
(The file_id column occurs in these DB tables:

Also maybe to double check that all files have an article in DB:

SELECT af.article_id FROM article_files af LEFT JOIN articles a ON (a.article_id = af.article_id) WHERE a.article_id IS NULL


@bozana, I hadn’t noticed before, but there is a warning about a failed copy file operation right before the Fatal Error. I will check why this file is not there.

Both two selects you sent in the beggining of the last post return lines here. What could I do about it? Maybe deleting inconsistent records from review_assignments table?

I’ve already fixed everything related to section_id, file_id=0 and inexistent articles in articles_* tables.

@bozana There was some missing files on the files_dir folder. After copying the directory again, the installer passed the “provideSupplementaryFilesForReview” section.

Hi @GustavoTonini

OK, good to hear and know! :slight_smile:
So the upgrade run through successfully, i.e. without warnings/errors?


@bozana Unfortunatelly another error occurred: OJS upgrade error "Unknown locale component".

Hi @GustavoTonini

Hmmm… it seems the error message comes from here: pkp-lib/PKPLocale.inc.php at ojs-stable-3_1_1 · pkp/pkp-lib · GitHub. Would it be possible for you to debug and output the variable $component directly before that fatalError function?


Hello @bozana, after debbuging I found that it was caused by NULL values on the column articles.locale. We’ve fixed the locale and the upgrade passed this step.


1 Like