Pkp-lib: [OJS] Uploading a new Galley file and selecting "Change file" corrupts the uploaded file

Created on 23 Oct 2017  路  23Comments  路  Source: pkp/pkp-lib

OJS 3.0.2. This happens at least when using the quicksubmit plugin, most likely with other similar file uploads as well.

  1. Add new article
  2. Enter metadata
  3. "Add galley"
  4. Enter a galley label and save
  5. Enter article component
  6. Upload a new file
  7. Click "Change file" and upload the same file again
  8. The system asks you if this is a new file or revision, leave the default selection and continue
    2017-10-23 10 10 21 am
  9. The file is uploaded and the modal window closes. The "PDF" is shown in the grid.
  10. Publish the article and the go to the workflow of that article => The galley grid is not loading
    2017-10-23 10 10 59 am

Related errors:

[23-Oct-2017 10:07:10 Europe/Helsinki] PHP Warning:  assert(): Assertion failed in /home/c2teihrj/public_html/ojs/lib/pkp/classes/notification/managerDelegate/EditingProductionStatusNotificationManager.inc.php on line 188
[23-Oct-2017 10:07:10 Europe/Helsinki] PHP Warning:  assert(): Assertion failed in /home/c2teihrj/public_html/ojs/lib/pkp/classes/notification/managerDelegate/EditingProductionStatusNotificationManager.inc.php on line 188
[23-Oct-2017 10:09:56 Europe/Helsinki] PHP Warning:  assert(): Assertion failed in /home/c2teihrj/public_html/ojs/lib/pkp/classes/notification/managerDelegate/EditingProductionStatusNotificationManager.inc.php on line 188
[23-Oct-2017 10:09:56 Europe/Helsinki] PHP Warning:  assert(): Assertion failed in /home/c2teihrj/public_html/ojs/lib/pkp/classes/notification/managerDelegate/EditingProductionStatusNotificationManager.inc.php on line 188
[23-Oct-2017 10:10:33 Europe/Helsinki] PHP Warning:  assert(): Assertion failed in /home/c2teihrj/public_html/ojs/lib/pkp/controllers/api/file/linkAction/FileLinkAction.inc.php on line 42
[23-Oct-2017 10:10:33 Europe/Helsinki] PHP Fatal error:  Call to a member function getFileId() on null in /home/c2teihrj/public_html/ojs/lib/pkp/controllers/api/file/linkAction/FileLinkAction.inc.php on line 46
[23-Oct-2017 10:10:50 Europe/Helsinki] PHP Warning:  assert(): Assertion failed in /home/c2teihrj/public_html/ojs/lib/pkp/controllers/api/file/linkAction/FileLinkAction.inc.php on line 42
[23-Oct-2017 10:10:50 Europe/Helsinki] PHP Fatal error:  Call to a member function getFileId() on null in /home/c2teihrj/public_html/ojs/lib/pkp/controllers/api/file/linkAction/FileLinkAction.inc.php on line 46

All 23 comments

@ajnyga, I cannot reproduce this any more. Could you please try in your 3.1 installation, if this still happens? THANKS!!!

Hmm, interesting. On my own server I have a OJS installation for test purposes. I installed it with 3.0.2 and upgraded that to 3.1 a while ago.

After the upgrade the quicksubmit plugin is missing (I replaced all the files when upgrading and the 3.1 package does not have that included). But now that I try to go to the plugin gallery and download the quicksubmit plugin, it says that my quicksubmit plugin is up to date. So without ftp access I would be stuck. This is probably not the way this should work with upgrades?

Edit: had to remove the plugin manually from the versions table.

@ajnyga, maybe this fix solves the problem: https://github.com/pkp/pkp-lib/issues/2956 ?

I get the same problem described above with 3.1 and the latest quicksubmit:

2017-11-09 05 26 20 pm

Do you have more than one locale active when you test it?

Hmm... Do you mean production discussion or galley files?
Yes, I have several languages and was uploading in a journal primary language...
EDIT: Oh, I see, the problem is when you go to the production page...

Yes exactly, the galleys grid does not load.

Hmmm... I cannot reproduce it in that way -- everything is fine in such a case, but when I cancel the file upload then I get that problem... When canceling the file upload the file is removed from the DB submission_files, but not from the table submission_galleys...

Do first upload a file and then right away change the file you uploaded and
do you upload the same file again and get the "possible duplication" modal?

I can reproduce this consistently.

Strange -- I do upload the same file and do not get that "possible duplication" modal :-O -- my file seems to be just replaced...

I believe I figured out where is the problem -- the file is assigned to the galley too early -- and in your case maybe the wrong fileId -- that then does not exist any more, but it stays in the submission_galleys table...

I think I tested this with a png file, a screen shot. Could that be related?

I'll check that too...

oh but, originally I had a htm file. I think I've seen a variable somewhere that is used to define if a file is regarded as a copy of the same file. In config.inc.php I think. But do not have a clue how it works.

@ajnyga, these PRs solve my problem. It could be that this would solve your problem as well -- if for example the function deleteFile is called also in your case... Would it be possible for you to test? -- It will not solve the existing wrong associations between files and galleys, so you would need to try to reproduce it again/anew, with the patch...
And I will continue to try to reproduce that case and to get that "possible duplication" modal... THANKS!!!

Ah, wait, I will have to do a correction...
EDIT: somehow I reproduced your problem -- the patch above does not fix it...

Ok, let me know if there is something I can test.

OK, I think I figured it out: your case happens when there are already old files with the same file name in the DB associated with that galley, for some reason -- maybe because it was functioning wrong till now i.e. these cases found here were not considered.
In that case, first the new file is created and associated with the galley, but then, when one chooses the file to be the revision of the existing, the file id and revision changes, but the galley file id does not.
Now everything should work ok, I hope...
@ajnyga, could you please test it now? Sorry... and THANKS!

Note for me: I checked the galley files, but the review rounds should be also tested, s. function _attachEntities here: https://github.com/pkp/pkp-lib/blob/master/controllers/wizard/fileUpload/PKPFileUploadWizardHandler.inc.php#L322

The pr's solve the original issue @bozana!

@asmecher, could you review the PRs above?
Note that I removed the stageAssignments check for detaching the dependent files i.e. for deleteReviewRoundAssignment in deleteFile, because also the managers/editors/admins that are not assigned could delete a file. And that I then consider those 3 file stages for that: SUBMISSION_FILE_REVIEW_FILE, SUBMISSION_FILE_REVIEW_ATTACHMENT, SUBMISSION_FILE_REVIEW_REVISION.
Thanks!!!

Looks good, @bozana, please go ahead!

the problem occurs because of an insert record failure in the galley submission table. example
UPDATE submission_galleys SET file_id = '3916' WHERE galley_id = 798;

Was this page helpful?
0 / 5 - 0 ratings