It seems like you would get only one row when executing that new SQL:
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
That would be this line, I think:
| 519 | 7763 | 5085 | | | NULL | 2016-08-30 | 1 | 2016-08-30 13:50:48 | 2 |
And it seems like something goes wrong here ojs/Upgrade.inc.php at ojs-3_1_1-2 · pkp/ojs · GitHub – maybe that that file could not be copied so that there is no newFileId there.
Do you have that file in your DB and files folder? – In the DB table article_files there should be a file with the ID = 7763. And can you find that file somewhere in your files folder, for that article 5085?
You would also need to address all the previous upgrade warnings: I see there were for example some warnings about some missing files, e.g. “WARNING: Unable to find a match for “5078-7748-1-LE.docx” in “/opt/ojs-obib-files/journals/8//articles/5078/”. Skipping this file.”
This warning/error means that the file was found in the DB, but not in the files folder and thus it could not be migrated/upgraded properly.
It would be best to go to those files using the GUI and upload the correct files again or delete them – do this via the GUI, in order to keep/remove all needed dependencies in the DB correctly.