deleteSubmissions.php CLI won't delete missing submissions after OJS 3.3.0.11 upgrade

Describe the issue or problem
We are upgrading from OJS 3.1 to 3.3.0.10 and met the issues described in Cron job fails ReviewReminder after OJS 3.2.1 upgrade - #12 by eddoff I get some submissions which creates another error:

PHP Fatal error: Uncaught Error: Call to a member function getStatus() on null in /var/www/boap-ojs/lib/pkp/classes/submission/reviewRound/ReviewRoundDAO.inc.php:238

Steps I took leading up to the issue

  1. I followed the thread linked above, which mirrored my issues exactly, until I met the current error message.
  2. Ran query to change submissions without owner to belong to admin account.
  3. I ran a script with sudo -u apache php deleteSubmissions.php N once for each of the 140 entries I identified as belonging to deleted journals.
  4. 10 of the entries returned PHP Fatal error: Uncaught Error: Call to a member function getStatus() on null in /var/www/boap-ojs/lib/pkp/classes/submission/reviewRound/ReviewRoundDAO.inc.php:238

What application are you using?
OJS 3.3.0-11

Additional information
Full error output of the cli:

PHP Fatal error:  Uncaught Error: Call to a member function getStatus() on null in /var/www/boap-ojs/lib/pkp/classes/submission/reviewRound/ReviewRoundDAO.inc.php:238
Stack trace:
#0 /var/www/boap-ojs/lib/pkp/classes/services/PKPSubmissionFileService.inc.php(530): ReviewRoundDAO->updateStatus()
#1 /var/www/boap-ojs/lib/pkp/classes/submission/PKPSubmissionDAO.inc.php(129): PKP\Services\PKPSubmissionFileService->delete()
#2 /var/www/boap-ojs/classes/submission/SubmissionDAO.inc.php(51): PKPSubmissionDAO->deleteById()
#3 /var/www/boap-ojs/tools/deleteSubmissions.php(56): SubmissionDAO->deleteById()
#4 /var/www/boap-ojs/tools/deleteSubmissions.php(62): SubmissionDeletionTool->execute()
#5 {main}
  thrown in /var/www/boap-ojs/lib/pkp/classes/submission/reviewRound/ReviewRoundDAO.inc.php on line 238

It seems

SELECT * FROM review_rounds rr   INNER JOIN review_round_files rrf ON rr.review_round_id = rrf.review_round_the id   WHERE rrf.submission_file_id =  ?

returns empty rows in the function getBySubmissionFileId($submissionFileId) of ReviewRoundDAO.

I’ve confirmed that the submission_file_id’s aren’t present in our review_round_files table, but I am uncertain on how to debug further, or what to delete.

Hi @OyvindLGjesdal

Have you checked this approach suggest for a similar issue on Github?

Likely, you may have some orphans entries in some tables on your DB.

Best,
Israel

Thank you @israel.cefrin I’ve looked at the thread. I’m unsure exactly in which tables I should delete rows for the script to run successfully, or if I should just try to delete the submissions from the submission table ( and where constrained) until I am able to delete rogue submissions? Should I just traverse on the foreign keys until I can delete the submissions themselves? I thought maybe it would be safer to use the deleteSubmission script, which was mentioned in my first link.

If I apply this patch

diff --git a/classes/notification/managerDelegate/PendingRevisionsNotificationManager.inc.php b/classes/notification/managerDelegate/PendingRevisionsNotificationManager.inc.php
index 6e954fd..d99633a 100644
--- a/classes/notification/managerDelegate/PendingRevisionsNotificationManager.inc.php
+++ b/classes/notification/managerDelegate/PendingRevisionsNotificationManager.inc.php
@@ -137,7 +137,7 @@ class PendingRevisionsNotificationManager extends NotificationManagerDelegate {
                        $removeNotifications = true;
                }

-               if ($removeNotifications) {
+               if ($removeNotifications && isset($context)) {
                        $context = $request->getContext();
                        $notificationDao = DAORegistry::getDAO('NotificationDAO'); /* @var $notificationDao NotificationDAO */
                        $notificationDao->deleteByAssoc(ASSOC_TYPE_SUBMISSION, $submissionId, $userId, $this->getNotificationType(), $context->getId());
diff --git a/classes/submission/reviewRound/ReviewRoundDAO.inc.php b/classes/submission/reviewRound/ReviewRoundDAO.inc.php
index 8698d54..53172d6 100644
--- a/classes/submission/reviewRound/ReviewRoundDAO.inc.php
+++ b/classes/submission/reviewRound/ReviewRoundDAO.inc.php
@@ -235,6 +235,7 @@ class ReviewRoundDAO extends DAO {
         */
        function updateStatus($reviewRound, $status = null) {
                assert(is_a($reviewRound, 'ReviewRound'));
+                if(!is_null($reviewRound)) {
                $currentStatus = $reviewRound->getStatus();

                if (is_null($status)) {
@@ -249,7 +250,7 @@ class ReviewRoundDAO extends DAO {
                        // Update the data in object too.
                        $reviewRound->setStatus($status);
                }
-       }
+       }}


        /**

before running the deleteSubmissions.php, the submissions seems to be deleted afterwards, and I don’t get further errors. I think of doing this and removing the patch after deletion. Does this make sense?