Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activity Log fails to load when a file has been uploaded to a discussion message that was deleted #7453

Closed
zalamuia opened this issue Nov 12, 2021 · 7 comments
Labels
Bug:1:Minor A bug found in uncommon paths, with low consequences, limited users or has an easy workaround
Milestone

Comments

@zalamuia
Copy link

Describe the bug
Please tell us what happens, what you expected to happen, and why you think it is a bug in the software.
I am using OJS 3.3.0.8 based on

OS platform | Linux
PHP version | 7.4.15
Apache version | Apache/2.4.6 (CentOS)
Database driver | mysql
Database server version | 5.5.60-MariaDB

It is found that some of the Activity Log can't be visible if the author deleted some of the notes. I just noticed recently at the production stage, the author deleted some conversions and I could not able to upload files at the copyediting stage as well as I am unable to view the activity log.

When I checked the database I have seen discontinued note id

Then I have added those missing ID's by copying the existing record then I managed to see the activity log and upload the file.

Please find the attached picture in a sequence.
InfiniteLoop
Notes_Deleted_Screenshot 2021-11-12 162249-L

Added two records by copying from one of the conversation by changing the note id

Screenshot 2021-11-12 163437_enteredRecord

after added two records

Act_log_after_added

I also faced this problem in many articles and could not be managed to identify the root cause of the problem. However, today I was communicating with the authors and noticed that the uploaded file with communication is missing and I tried to see the activity but I could not manage to see it. I could manage to find the database since I have access to the database and added those missing data to see the functionality.

I hope that the issue can be resolved if the author deleted some conversations.

Thanks.

Zahirul

@NateWr
Copy link
Contributor

NateWr commented Nov 15, 2021

Hi @zalamuia, please provide reproduction steps we can follow to reproduce the problem in our local development environment, like the following:

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

@zalamuia
Copy link
Author

The situation occurred earlier too. However, recently I was following the conversation and found the root cause.

There is no problem with the system of that particular paper until the paper has been sent to production.

  1. There are few discussions in the Copyediting stage after the author is notified by the editor. At this stage, the editor tried to update copyedited file but failed to update it. The Editor send the article to the Production stage from the Copyrditig stage and notified the author and add the file as discussion. There are few discussions with the editor and the author. During this process, the editor found that one discussion is missing and the editor tried to check the activity via Activity log but failed to view the activity, infinite looping without showing a single activity.
  2. In order to create this situation the following steps may be taken
    i. Paper submission by the author. Accept paper. The editor needs to notify via participant author. The author needs to reply and continue a few correspondences.
    ii. Author needs to delete 1 or 2 earlier conversations in order to break the sequence.

iii. Editor send the paper to the production stage and notify the author via participant notification.

iv. Try to upload/update paper in the copyediting stage as Copyedited.

v. Start a few conversations with the author as an editor

vi. Again author deleted 1/2 earlier conversation.

vii. Probably paper can't be uploaded at stage iv and activity log can not be viewed.

viii. Open the database check the NOTES table. I used phpMyAdmin. Sort the notes table by date created and check the sequence of the note_id

Thanks.

NateWr added a commit to NateWr/pkp-lib that referenced this issue Nov 16, 2021
@NateWr
Copy link
Contributor

NateWr commented Nov 16, 2021

Thanks @zalamuia. I was able to reproduce the problem with the following steps:

  1. Login as editor, go to a submission and create a discussion with an author.
  2. Login as author, reply to discussion and upload file with the reply.
  3. As author, delete the reply to the discussion.
  4. Login as editor, go to the submission, view activity log.
  5. See error: the activity log does not load.

The following error is in the error logs:

[16-Nov-2021 09:51:33 Europe/London] PHP Fatal error:  Uncaught Error: Call to a member function getAssocId() on null in /ojs-330/lib/pkp/classes/services/PKPSubmissionFileService.inc.php:774
Stack trace:
#0 /ojs-330/lib/pkp/controllers/grid/eventLog/EventLogGridRow.inc.php(79): PKP\Services\PKPSubmissionFileService->getWorkflowStageId(Object(SubmissionFile))
#1 /ojs-330/lib/pkp/classes/controllers/grid/GridHandler.inc.php(1068): EventLogGridRow->initialize(Object(Request))
#2 /ojs-330/lib/pkp/classes/controllers/grid/GridHandler.inc.php(985): GridHandler->_getInitializedRowInstance(Object(Request), 3, Object(SubmissionEventLogEntry))
#3 /ojs-330/lib/pkp/classes/controllers/grid/GridHandler.inc.php(1033): GridHandler->renderRowsInternally(Object(Request), Array)
#4 /ojs-330/lib/pkp/classes/controllers/grid/GridHandler.inc.php(923): GridHandler->renderGridBodyPartsInternally(Object(Request))
#5 /ojs-330/li in /ojs-330/lib/pkp/classes/services/PKPSubmissionFileService.inc.php on line 774

PR:
#7457

Tests:
pkp/ojs#3227

@asmecher this happens because when a file is uploaded to a discussion, a submission log entry is recorded in the activity log:

Revision "filename.docx" was uploaded for file 137.

This then lingers after the related query note has been deleted. Do you think this log entry should be there, though? A discussion file isn't really a "revision". For the main branch, should we leave it as-is, remove the log entry, or modify it to say something like "A file was uploaded to the discussion ..."?

@NateWr NateWr added this to the 3.3.0-9 milestone Nov 16, 2021
@NateWr NateWr added the Bug:1:Minor A bug found in uncommon paths, with low consequences, limited users or has an easy workaround label Nov 16, 2021
@NateWr NateWr changed the title Activity Log failed to show the activity if the author deleted some of the conversation Activity Log fails to load when a file has been uploaded to a discussion message that was deleted Nov 16, 2021
@asmecher
Copy link
Member

My instinct is to leave log entries in place, but make them behave better when they refer to external content that does not exist. If we could use a proper foreign key for log entries, that would mean an ON DELETE NULL clause, e.g. when a file or note that is referred to gets deleted, the log entry's foreign key gets set to NULL. But we're using a polymorphic relationship (assoc_type / assoc_id), which means we can't set/enforce a foreign key. So I'd be just as happy to let the ID go stale, but have checks in the PHP to ensure that an attempt to fetch an object actually returned with something.

@NateWr
Copy link
Contributor

NateWr commented Nov 17, 2021

Ok thanks @asmecher. I've merged that PR to stable-3_3_0 and it looks like you already fixed the bug in main with a1cf069

@NateWr NateWr closed this as completed Nov 17, 2021
@eirikhanssen
Copy link
Contributor

eirikhanssen commented Nov 17, 2021

@asmecher and @NateWr I had a very similar problem with ojs 3.3.0-8. When trying access the activity log it would not finish loading.

I resolved this by adding the changes in a1cf069, and in addition I had to also add a check to see if $reviewRound was null for
case SUBMISSION_FILE_INTERNAL_REVIEW_REVISION: on line 766 in PKPSubmissionFileService.inc.php
and add a similar "return null" statement in the case it was null, so I suggest you add a fix to this place also.

case SUBMISSION_FILE_INTERNAL_REVIEW_REVISION:
    $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); /* @var $reviewRoundDao ReviewRoundDAO */
     $reviewRound = $reviewRoundDao->getBySubmissionFileId($submissionFile->getId());

      // The file should be associated with a review round. If not, fail.
      if(is_null($reviewRound)) {
          return null;
       }

    // Get the associated stage.
    return $reviewRound->getStageId();

The error message I got was:
[17-Nov-2021 14:27:24 Europe/Oslo] PHP Notice: Undefined index: stageId in /var/www/vhosts/ojs-3.3.0-8/lib/pkp/controllers/grid/eventLog/SubmissionEventLogGridHandler.inc.php on line 111
[17-Nov-2021 14:27:24 Europe/Oslo] PHP Notice: Undefined variable: query in /var/www/vhosts/ojs-3.3.0-8/lib/pkp/classes/services/PKPSubmissionFileService.inc.php on line 784
[17-Nov-2021 14:27:24 Europe/Oslo] PHP Fatal error: Uncaught Error: Call to a member function getAssocType() on null in /var/www/vhosts/ojs-3.3.0-8/lib/pkp/classes/services/PKPSubmissionFileService.inc.php:784
Stack trace:
#0 /var/www/vhosts/ojs-3.3.0-8/lib/pkp/controllers/grid/eventLog/EventLogGridRow.inc.php(79): PKP\Services\PKPSubmissionFileService->getWorkflowStageId(Object(SubmissionFile))
#1 /var/www/vhosts/ojs-3.3.0-8/lib/pkp/classes/controllers/grid/GridHandler.inc.php(1066): EventLogGridRow->initialize(Object(Request))
#2 /var/www/vhosts/ojs-3.3.0-8/lib/pkp/classes/controllers/grid/GridHandler.inc.php(983): GridHandler->_getInitializedRowInstance(Object(Request), 0, Object(SubmissionEventLogEntry))
#3 /var/www/vhosts/ojs-3.3.0-8/lib/pkp/classes/controllers/grid/GridHandler.inc.php(1031): GridHandler->renderRowsInternally(Object(Request), Array)
#4 /var/www/vhosts/ojs-3.3.0-8/lib/pkp/classes/contro in /var/www/vhosts/ojs-3.3.0-8/lib/pkp/classes/services/PKPSubmissionFileService.inc.php on line 784

@NateWr
Copy link
Contributor

NateWr commented Nov 17, 2021

Thanks @eirikhanssen. Can you file a new issue with those details?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug:1:Minor A bug found in uncommon paths, with low consequences, limited users or has an easy workaround
Projects
None yet
Development

No branches or pull requests

4 participants