Upgrade from OJS 2.4.7 to 3.0.1 fails

Hi @asmecher
for me instead the php error log message is

PHP Warning: assert(): Assertion failed in /var/www/vhosts/geospatialhealth.org/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 285
<h1.>Invalid file!</h1.>ojs2: Invalid file!

I put the point to have the code displayed.
How I should I proceed? I updating from 2.4.8.2 to 3.1.1.2.

This is php log:

[pre-install]
[load: upgrade.xml]
[version: 3.1.1.2]

[code: Installer Installer::checkPhpVersion]

[code: Installer Installer::syncSeriesAssocType]
[data: dbscripts/xml/upgrade/2.4.0_preupdate_usageStatistics.xml (skipped)]
[data: dbscripts/xml/upgrade/2.4.0_preupdate_usageStatistics2.xml (skipped)]

[code: Installer Installer::removeReviewEntries]
[data: dbscripts/xml/upgrade/3.0.0_preupdate.xml]
[data: dbscripts/xml/upgrade/3.0.0_adaptTimedViews.xml (skipped)]
[data: dbscripts/xml/upgrade/3.0.0_adaptReferrals.xml]
[data: dbscripts/xml/upgrade/3.0.0_adaptBooksForReview.xml]
[data: dbscripts/xml/upgrade/remove_timed_views_bots.xml (skipped)]
[data: dbscripts/xml/upgrade/3.0.0_preupdate_commentsToEditor.xml]
[data: dbscripts/xml/upgrade/3.1.0_preupdate_review_assignments.xml]
[data: dbscripts/xml/upgrade/3.1.0_preupdate_notes.xml]
[data: dbscripts/xml/upgrade/3.1.0_preupdate_payments.xml]
[data: dbscripts/xml/upgrade/3.1.1_preupdate_citations.xml]
[schema: lib/pkp/xml/schema/common.xml]
[schema: lib/pkp/xml/schema/log.xml]
[schema: lib/pkp/xml/schema/announcements.xml]
[schema: lib/pkp/xml/schema/scheduledTasks.xml]
[schema: lib/pkp/xml/schema/temporaryFiles.xml]
[schema: lib/pkp/xml/schema/metadata.xml]
[schema: lib/pkp/xml/schema/reviews.xml]
[schema: lib/pkp/xml/schema/reviewForms.xml]
[schema: lib/pkp/xml/schema/controlledVocab.xml]
[schema: lib/pkp/xml/schema/submissions.xml]
[schema: lib/pkp/xml/schema/submissionFiles.xml]
[schema: lib/pkp/xml/schema/notes.xml]
[schema: lib/pkp/xml/schema/views.xml]
[schema: lib/pkp/xml/schema/genres.xml]
[schema: lib/pkp/xml/schema/tombstone.xml]
[schema: lib/pkp/xml/schema/rolesAndUserGroups.xml]
[schema: lib/pkp/xml/schema/metrics.xml]
[schema: lib/pkp/xml/schema/views.xml]
[schema: lib/pkp/xml/schema/libraryFiles.xml]
[schema: lib/pkp/xml/schema/navigationMenus.xml]
[schema: dbscripts/xml/ojs_schema.xml]
[data: dbscripts/xml/indexes.xml]

[code: Installer Installer::installDefaultNavigationMenus]

[code: Installer Installer::migrateStaticPagesToNavigationMenuItems]

[code: Installer Installer::migrateSRLocale]

[code: Installer Installer::concatenateIntoAbout]

[code: Installer Installer::concatenateIntoMasthead]

[code: Installer Installer::migrateCounterPluginUsageStatistics (skipped)]

[code: Installer Installer::migrateTimedViewsUsageStatistics (skipped)]

[code: Installer Installer::migrateDefaultUsageStatistics (skipped)]
[data: dbscripts/xml/upgrade/2.4.0_postUsageStatsMigration.xml (skipped)]
[data: dbscripts/xml/upgrade/2.4.0_postUsageStatsMigration2.xml (skipped)]
[data: dbscripts/xml/upgrade/2.4.0_postCounterMigration.xml (skipped)]
[data: dbscripts/xml/upgrade/2.4.0_postTimedViewsMigration.xml (skipped)]
[data: dbscripts/xml/upgrade/3.0.0_change_assoc_type.xml]
[data: dbscripts/xml/upgrade/3.0.0_change_assoc_type_metrics.xml]
[data: dbscripts/xml/upgrade/3.0.0_settings.xml]

[code: Installer Installer::installDefaultGenres]

[code: Installer Installer::migrateArticleMetadata]
[data: dbscripts/xml/upgrade/3.0.0_update.xml]

[code: Installer Installer::clearDataCache]

[code: Installer Installer::migrateUserRoles]

[code: Installer Installer::fixReviewForms]

[code: Installer Installer::htmlifyEmailTemplates]
[note: docs/release-notes/README-BEACON]

[code: Installer Installer::installEmailTemplate]

[code: Installer Installer::installEmailTemplate]

[code: Installer Installer::installEmailTemplate]

[code: Installer Installer::installEmailTemplate]

[code: Installer Installer::installEmailTemplate]

[code: Installer Installer::installEmailTemplate]
[data: dbscripts/xml/upgrade/3.0.0_scheduledTasks.xml]

[code: Installer Installer::localizeCustomBlockSettings]

[code: Installer Installer::convertEditorDecisionNotes]

[code: Installer Installer::convertQueries]

[code: Installer Installer::migrateFiles]

[code: Installer Installer::convertSupplementaryFiles]

[code: Installer Installer::provideSupplementaryFilesForReview]
PHP Warning: assert(): Assertion failed in /var/www/vhosts/geospatialhealth.org/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 285
<h1.>Invalid file!</h1.>ojs2: Invalid file!

Thanks for any help
Best

Tiziano

Hi everybody,
any help?

Hi @Tiziano

Do you have any file without revision or with revision = 0 or NULL in your database table article_files?

Best,
Bozana

Hi @bozana,
I checked and in the “revision” column the minimum number is 1. There is no one with number 0.
Is this the reason for the error?

Thanks for help.

Bye
Tiziano

Hi @Tiziano

Probably there is a reason for the error, we just have to figure it out :slight_smile:
If the revision is not the problem: is there maybe an entry in your DB table article_supplementary_files that contains a file_id that is not in the table article_files (but where remote_url is not null)? – Could you execute this SQL and post the results:
SELECT * FROM article_supplementary_files WHERE file_id NOT IN (SELECT file_id FROM article_files)

Thanks!
Bozana

@bozana
I have run the SQL and the result is this:

31

:grinning:

Hmmm… that looks OK :-\

Could you then please also execute this SQL:
SELECT a.journal_id, sf.* FROM article_supplementary_files sf, articles a WHERE a.article_id = sf.article_id AND sf.show_reviewers = 1 AND sf.remote_url IS NULL

Thanks!!!
Bozana

Ah, sorry, now I see – your results contain for some files with file_id = 0 (without the file), although they are not remote files.
I will patch the SQL to consider that as well…
Coming…

I already did the patch – and I’ve already forgotten about that :stuck_out_tongue:
Could you apply this change please: pkp/pkp#3783 consider supp files without file id in the migration by bozana · Pull Request #2009 · pkp/ojs · GitHub.
That should solve the problem.

Thanks @bozana, now i try this patch then I will let you know!

Bye
Tiziano

@bozana the update went all right, the only error that has viewed the update is:

[code: Installer Installer::moveReviewerFiles]
ERROR: Reviewer files with ID 925 from review assignment 131 could not be found in the database table submission_files

Thanks for your support!

Bye
Tiziano

Hi @Tiziano

Could you take a look in your DB table review_assignment, where review_id = 131. It seems like there is a review_file_id = 925 there, but that file actually does not exist (in article_files table). If so, you could go via the UI to that submission, to see what how the situation looks like there for that review assignment i.e. what file should actually be there, why is it missing, etc. Maybe you can also see if that file is in your files folder. And finally, you might eventually have to remove that and upload a new/correct/existing file there.

Best,
Bozana

1 Like

@bozana, thanks! you gave me a good suggestion! I will do the necessary checks in the coming days, meanwhile the site is up and running and updated to the latest version. Thank you for your help.
Bye
Tiziano

Hi @bozana,
I try to upgrade a very large journal from version 2.4 to 3.1.1-2 and ran into the same problems. But unfortunately applying the changes in the /Upgrade.inc.php (pkp/pkp#3783 consider supp files without file id in the migration by bozana · Pull Request #2009 · pkp/ojs · GitHub) didn’t solve my problem, the upgrade can’t be accomplished. I get this output:


PHP Warning: Declaration of SubmissionFileDAO::fromRow($row) should be compatible with PKPSubmissionFileDAO::fromRow($row, $fileImplementation) in /opt/ojs-obib/classes/article/SubmissionFileDAO.inc.php on line 23

[code: Installer Installer::migrateFiles]
WARNING: Unable to find a match for “5078-7748-1-LE.docx” in “/opt/ojs-obib-files/journals/8//articles/5078/”. Skipping this file.
WARNING: Unable to find a match for “5200-9174-1-SM.phtml” in “/opt/ojs-obib-files/journals/8//articles/5200/”. Skipping this file.

[code: Installer Installer::convertSupplementaryFiles]

[code: Installer Installer::provideSupplementaryFilesForReview]

Invalid file!

ojs2: Invalid file!

Do you any idea what works wrong?

The output of the above called sql statement is:

±--------±--------±-----------±-----±---------±-----------±-------------±---------------±--------------------±----+
| supp_id | file_id | article_id | type | language | remote_url | date_created | show_reviewers | date_submitted | seq |
±--------±--------±-----------±-----±---------±-----------±-------------±---------------±--------------------±----+
| 150 | 0 | 4803 | NULL | NULL | NULL | 2015-06-21 | NULL | 2015-06-21 13:59:11 | 0 |
| 519 | 7763 | 5085 | | | NULL | 2016-08-30 | 1 | 2016-08-30 13:50:48 | 2 |
| 657 | 0 | 5159 | | | NULL | 2016-12-12 | 1 | 2016-12-12 15:23:36 | 0 |
| 682 | 0 | 5183 | | | NULL | 2020-12-20 | 1 | 2017-02-23 09:12:31 | 0 |
| 686 | 0 | 5183 | | | NULL | 2009-11-20 | 0 | 2017-02-23 20:14:10 | 4 |
| 1043 | 0 | 5363 | NULL | NULL | NULL | 2018-06-08 | NULL | 2018-06-08 11:19:55 | 0 |
±--------±--------±-----------±-----±---------±-----------±-------------±---------------±--------------------±----+

Thanks a lot,
Anna

Hi @akku

You would need to apply this patch/change: pkp/pkp#3783 consider supp files without file id in the migration by bozana · Pull Request #2009 · pkp/ojs · GitHub. Then start the upgrade again, but with the clean backup form OJS 2 data.

Best,
Bozana

Hi @bozana,

I already tried this yesterday, before I wrote, but the result is above.
Here my changes just to be sure:

	//$suppFilesResult = $submissionFileDao->retrieve('SELECT a.context_id, sf.* FROM article_supplementary_files sf, submissions a WHERE a.submission_id = sf.article_id AND sf.show_reviewers = 1 AND sf.remote_url IS NULL');
	
	$suppFilesResult = $submissionFileDao->retrieve('SELECT a.context_id, sf.* FROM article_supplementary_files sf, submissions a WHERE a.submission_id = sf.article_id AND sf.file_id <> 0 AND sf.show_reviewers = 1 AND sf.remote_url IS NULL');

Did I miss anything?
thanks,
Anna

Hi @akku

Hmmm…

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.

Best,
Bozana

1 Like

Hi @bozana,

thank you for your great support! I checked the three incorrect db entries, deleted the first entry (file id 7763) and corrrected the other database entries or file names.

After these corrections the upgrade script ran without problems :smile::tada:

best regards,
Anna

1 Like

Hi @bozana, i’m having same issue when upgrading from 2.4.8 to 3.1.1.2. This is my upgrade log https://paste.fedoraproject.org/paste/ider0w0WRY6ctf0gXeX8Ng

And running the mention SQL i get this: https://snag.gy/trJhYl.jpg

Really doesn’t know which record i should erase. Thanks.

I was able to fix, see: Upgrade OJS 2.4.8 to OJS 3.1: Error in version - #18 by lucasdiedrich