Upgrade OJS 2.4.8 to OJS 3.1 failed with PHP Fatal error: Call to a member function getContextId() on null in ReviewAssignment.inc.php on line 517


#1

Hi everyone I have an problem with respect to the upgrading from a Journal in OJS 2.4.8 to OJS 3.1.

I am upgrading using the following command

php tools/upgrade.php upgrade

The first time my upgrading process finished with the following messages:

ERROR: Reviewer files with ID 168293 from review assignment 6823 could not be found in the database table submission_files
ERROR: Reviewer files with ID 168947 from review assignment 6953 could not be found in the database table submission_files
[code: Installer Installer::fixAuthorGroup]
[data: dbscripts/xml/upgrade/3.0.0_reviewer_files.xml]
[code: Installer Installer::removeCancelledReviewAssignments]
PHP Fatal error:  Call to a member function getContextId() on null in /var/www/html/iisue_prev/lib/pkp/classes/submission/reviewAssignment/ReviewAssignment.inc.php on line 517

I have read in this topic Error Upgrade 2.4.8.2 to 3.1.0, there said for resolve the error:

ERROR: Reviewer files with ID 168293 from review assignment 6823 could not be found in the database table submission_files

We have to remove the rows in the review_assignments table where the reviewer_file_id field is in (168293, 168947) for my specific case, then I had tried the upgrading process with a clean database restore again, but the upgrading process has finished with the same last error:

[code: Installer Installer::moveReviewerFiles]
[code: Installer Installer::fixAuthorGroup]
[data: dbscripts/xml/upgrade/3.0.0_reviewer_files.xml]
[code: Installer Installer::removeCancelledReviewAssignments]
PHP Fatal error:  Call to a member function getContextId() on null in /var/www/html/iisue_prev/lib/pkp/classes/submission/reviewAssignment/ReviewAssignment.inc.php on line 517

Note please that the first 2 errors aren’t present now.

Someone of the PKP team knows how to resolve this last error:

PHP Fatal error: Call to a member function getContextId() on null in /var/www/html/iisue_prev/lib/pkp/classes/submission/reviewAssignment/ReviewAssignment.inc.php on line 517


#2

Hi @juancure

Hmmm… It seems like you have an submission_id in your DB table review_assignments that does not exist in articles :open_mouth:
Could you try this SQL statement on your 2.4.8 DB (using MySQL):

SELECT * FROM review_assignments WHERE submission_id NOT IN (SELECT article_id FROM articles)

Best,
Bozana


#3

Hi @bozana thanks a lot for your response.

I tried more than twice times the upgrade from OJS 2.4.8 to OJS 3.1 and always finished with the same error, PHP Fatal error: Call to a member function getContextId() on null in /var/www/html/iisue_prev/lib/pkp/classes/submission/reviewAssignment/ReviewAssignment.inc.php on line 517

However I have made the upgrade to OJS 3.0.2 and works in the first try. It has finished with the Successfully upgraded to version 3.0.2.0

Now with respect to response, I have restored my 2.4.8 DB, and tried the SQL statement:

SELECT review_id, submission_id, reviewer_id, reviewer_file_id, round FROM review_assignments WHERE submission_id NOT IN (SELECT article_id FROM articles);

I left a fragment of the SQL answer:

+-----------+---------------+-------------+------------------+-------+
| review_id | submission_id | reviewer_id | reviewer_file_id | round |
+-----------+---------------+-------------+------------------+-------+
|       707 |         23912 |         436 |             NULL |     1 |
|      5980 |         52794 |       35392 |             NULL |     1 |
|      1767 |         29578 |        4668 |             NULL |     1 |
|      5981 |         52794 |       35393 |             NULL |     1 |
|      4644 |         46741 |       28354 |             NULL |     1 |
|      4645 |         46741 |       28356 |             NULL |     1 |
|      4646 |         46756 |       16192 |             NULL |     1 |
|      4647 |         46756 |       16255 |             NULL |     1 |
|      4648 |         46758 |       28364 |             NULL |     1 |
|      4649 |         46758 |       28365 |           145146 |     1 |
|      4652 |         43413 |         516 |             NULL |     1 |
|      4653 |         43413 |        9912 |             NULL |     1 |
|      4654 |         46780 |       28388 |             NULL |     1 |
|      4656 |         43413 |       28390 |           130013 |     1 |
|      4657 |         46792 |       16281 |             NULL |     1 |
|      4658 |         46792 |       28396 |             NULL |     1 |
|      4659 |         43413 |       28397 |             NULL |     1 |
|      4660 |         46792 |       28398 |             NULL |     1 |
...
+-----------+---------------+-------------+------------------+-------+
147 rows in set (0.00 sec)

What is the reason for what the upgrade works correctly for OJS 3.0.2 and not for 3.1?


#4

Hi @bozana

Starting with my resulting 3.0.2 DB, I have tried to upgrade it to OJS 3.1.0.1, and then I got the same result, I have got the following Warnings and Error messages:

[data: dbscripts/xml/upgrade/3.1.0_update_a.xml]
[code: Installer Installer::fixGenreIdInFileNames]
PHP Warning:  rename(/srv/iisue_dev/files/journals/81//articles/58450//attachment/58450-1-169156-1-13-20171210.pdf,/srv/iisue_dev/files/journals/81//articles/58450//attachment/58450-1-169156-1-13-20171210.pdf): No existe el fichero o el directorio in /var/www/html/iisue_dev/classes/install/Upgrade.inc.php on line 2490
Unable to move "/srv/iisue_dev/files/journals/81//articles/58450//attachment/58450-1-169156-1-13-20171210.pdf" to "/srv/iisue_dev/files/journals/81//articles/58450//attachment/58450-1-169156-1-13-20171210.pdf".

And after all these Warnings messages, I have got the following Errors messages:

[code: Installer Installer::repairKeywordsAndSubjects]
[code: Installer Installer::enabledSitePlugins]
[code: Installer Installer::moveCSSFiles]
[code: Installer Installer::repairSuppFilesFilestage]
[code: Installer Installer::moveReviewerFiles]
ERROR: Reviewer files with ID 168293 from review assignment 6823 could not be found in the database table submission_files
ERROR: Reviewer files with ID 168947 from review assignment 6953 could not be found in the database table submission_files
PHP Warning:  rename(/srv/iisue_dev/files/journals/81//articles/58586/submission/review/58586-1-169144-1-4-20171206.docx,/srv/iisue_dev/files/journals/81//articles/58586/submission/review/attachment/58586-1-169144-1-5-20171206.docx): No existe el fichero o el directorio in /var/www/html/iisue_dev/classes/install/Upgrade.inc.php on line 2003
ERROR: Unable to move "/srv/iisue_dev/files/journals/81//articles/58586/submission/review/58586-1-169144-1-4-20171206.docx" to "/srv/iisue_dev/files/journals/81//articles/58586/submission/review/attachment/58586-1-169144-1-5-20171206.docx".
PHP Warning:  rename(/srv/iisue_dev/files/journals/81//articles/58620/submission/review/58620-1-169152-1-4-20171208.docx,/srv/iisue_dev/files/journals/81//articles/58620/submission/review/attachment/58620-1-169152-1-5-20171208.docx): No existe el fichero o el directorio in /var/www/html/iisue_dev/classes/install/Upgrade.inc.php on line 2003
ERROR: Unable to move "/srv/iisue_dev/files/journals/81//articles/58620/submission/review/58620-1-169152-1-4-20171208.docx" to "/srv/iisue_dev/files/journals/81//articles/58620/submission/review/attachment/58620-1-169152-1-5-20171208.docx".
[code: Installer Installer::fixAuthorGroup]
[data: dbscripts/xml/upgrade/3.0.0_reviewer_files.xml]
[code: Installer Installer::removeCancelledReviewAssignments]
PHP Fatal error:  Call to a member function getContextId() on null in /var/www/html/iisue_dev/lib/pkp/classes/submission/reviewAssignment/ReviewAssignment.inc.php on line 517

My upgrade process finished with the same error. Do you know how can resolve this problem in my upgrading process, from OJS 2.4.8 to 3.1 or OJS 3.0.2 to 3.1? Do you think that the rows in review_assignments that its submission_id isn’t in articles table, are the cause of the problem?


[OJS 2.4.6] What is the best way to upgrade a OJS 2.4.6 with multiple journals to OJS 3.1.1-4?
#5

Hi @juancure

In the 3.0.2 update there were some bugs and some things/issues were not considered, that were then solved for 3.1. Thus, I think you should try to upgrade to 3.1.0.1 directly.
Unfortunately, it happens that the data in OJS 2.4.x is for some reason not consistent – I do not why and how this could happen, but it happened to several users already… – e.g. if an article/article file deletion could not be finished/executed till the end successfully.
Thus, maybe to try to solve the problems step-by-step…

It would be good if you could investigate what is wrong with those submissions/articles i.e. if they could be totally removed i.e. if those lines could be removed from the DB table review_assignements: these are the tables that have the column article_id or submission_id in OJS 2.4.x:
article_comments
article_files
article_galleys
article_search_objects
article_settings
article_supplementary_files
article_xml_galleys
articles
authors
books_for_review
comments
dataverse_files
dataverse_studies
edit_assignments
edit_decisions
metrics
object_for_review_assignments
pixel_tags
published_articles
referrals
review_rounds

Could you see if any of them also contains the missing submission, e.g. like this:

SELECT * FROM article_comments WHERE article_id IN (23912, 52794, 29578, 46741, 46756, 46758, 43413, 46780, 46792)

And also if there are appropriate folders in your files folder i.e. files/journals//articles// ?

After we solved that problem, we will see if another problem occurs – e.g. it could happen that some files are missing :frowning: – then go step-by-step further…
Please keep the original backup of your OJS 2.4.x installation!!! and make additionally a new backup after a problem has been fixed.

Best,
Bozana


#6

Hi @bozana thanks a lot for your response.

I need to resolve these problems in my upgrading process from 2.4.8 to 3.1.0.1, because I have worked some modifications that they have to be integrated to that version.

For what I have understood, I need to decide if the resulting rows of the SQL statement above whether will be deleted or still keep. I would try to follow the way you explained. Thanks for your response.


#7

Hi @bozana

I have investigated more about those submissions/articles in the mentioned tables above.

With the following SQL over the table article_comments:

SELECT article_id FROM article_comments WHERE article_id IN (SELECT submission_id FROM review_assignments WHERE submission_id NOT IN (SELECT article_id FROM articles) ORDER BY submission_id);

I have got 54 rows. I left you a little part of them:

+------------+
| article_id |
+------------+
|      43413 |
|      43477 |
|      43477 |
|      43477 |
|      43803 |
|      43803 |
|      46026 |
|      46026 |
|      46026 |
|      46026 |
|      46026 |

I have did until this point, the same test for article_files and article_galleys, but for these tables I have got 0 rows as answer.

I have checked the uploaded files directory too, and I have noticed that there aren’t any directory for all those submissions/articles resulting from the first SQL statement you suggested me to make.

What you suggest me for try the upgrading process again? Delete all those rows in the tables where they are? If yes, what is the better way to make it?

Thansk a lot for your valuable helping.


#8

Hi @juancure

Yes, if those articles are totally missing, then you can delete them from the DB. But be also aware that the DB tables are maybe connected, for example:
When you delete a row from the DB table review_assignments then you should also consider the appropriate review_id in the DB table review_form_responses. See e.g. this OJS function that deletes review assignments: https://github.com/pkp/pkp-lib/blob/ojs-2_4_8-2/classes/submission/reviewAssignment/PKPReviewAssignmentDAO.inc.php#L635.
You could also write a script similar to those in the folder tools/ and use that OJS function to do that. Let me know if you would like to do that and need any help…

The article comments are not connected to any other DB table, so you can delete the rows with missing articles there.

You could also check those other tables using the similar SQL as the first one above i.e. something like:

SELECT * FROM article_comments WHERE article_id NOT IN (SELECT article_id FROM articles);

If you find the similar rows with missing articles in other DB tables, you can write me and I can see if there is any other DB table to consider i.e. find the OJS function that does the deletion.

Also, do not forget to check the files folder – that articles are not there too.
And do not forget to backup after each step and keep all the backups :slight_smile:

Best,
Bozana


#9

Hi @bozana

Oh yes I would like to resolve this problem using an automatized way as building a script so I would be very grateful if you could lead me through this process. Well I have investigated more about the others tables, and I have found more missing articles within the mentioned tables.

These are the tables that have missing articles i.e I have executed a similar SQL as the first one above, only changing the name of the table and the field’s name whether called article_id or submission_id.

SELECT * FROM table WHERE article_id NOT IN (SELECT article_id FROM articles);

  1. article_comments with 63 rows
  2. article_xml_galleys with 36 rows
  3. authors with 5528 rows
  4. comments with 404367 rows
  5. metrics with 2481697 rows
  6. referrals with 141793 rows
  7. review_rounds with 82 rows

The rest of tables have returned Empty set.

I hope this information will be useful. Thanks in advance.

Best,
juancure


#10

Hi @juancure

Hmmm… That is really strange, that so many articles are missing i.e. so many table rows are affected :open_mouth: :frowning:
I am not sure if it would be maybe better to just solve the problem for the upgrade and leave everything else as is… Hmmm…

Here is a script that you could maybe use: https://github.com/bozana/ojs/blob/deleteMissingSubmissions/tools/deleteMissingSubmissions.php. You could eventually comment out some code lines, if you do not want to delete them all.
I haven’t considered the files in the files folder – I hope that they are all properly removed. Let me know if this is not the case and you would need the code for that as well.

Please, as always, back up everything!!! and after running the script i.e. after the removal check well if everything is all right with your installation.

Somehow I am confused that so much articles are missing and their ids are still in the DB… Could it be that something else is wrong with your installation? – Did you make any code changes? – Could it be that somehow wrong IDs are inserted into those tables? – Hmmm… I cannot understand that… :frowning:

Best,
Bozana


#11

Hi @bozana

I am sorry for answering until now. I went to a necessary vacation. But I have good news. I have got an “Successfully upgraded to version 3.1.0.1” from my original OJS 2.4 DB.

I have remove manually the rows in the following tables:

  1. review_form_responses
  2. review_assignments
  3. article_comments

in that order using the following SQL statements:

DELETE FROM review_form_responses WHERE review_id IN (SELECT review_id FROM review_assignments WHERE submission_id NOT IN (SELECT article_id FROM articles))

DELETE FROM review_assignments WHERE submission_id NOT IN (SELECT article_id FROM articles);

DELETE FROM article_comments WHERE article_id NOT IN (SELECT article_id FROM articles);

Then I have ran the command

$ php tools/upgrade.php upgrade

And I have got a bunch of warnings of kind of:

WARNING: Unable to find a match for "24133-42122-1-SM.pdf" in "/srv/iisue_dev/files/journals/81//articles/24133/". Skipping this file.

PHP Warning:  copy(/srv/iisue_dev/files/journals/81//articles/58576/attachment/58576-1-169098-1-13-20171118.docx): failed to open stream: No existe el fichero o el directorio in /var/www/html/iisue_dev/lib/pkp/classes/file/FileManager.inc.php on line 159
PHP Warning:  assert(): Assertion failed in /var/www/html/iisue_dev/lib/pkp/classes/submission/SubmissionFileDAODelegate.inc.php on line 124

And

ERROR: Unable to move "/srv/iisue_dev/files/journals/81//articles/58620/submission/review/58620-1-169152-1-4-20171208.docx" to "/srv/iisue_dev/files/journals/81//articles/58620/submission/review/attachment/58620-1-169152-1-5-20171208.docx".

But finally I have got a satisfactory "Successfully upgraded to version 3.1.0.1" message.

Thanks a lot for your orientation and help @bozana

Best,
@juancure


#12

Hi @juancure

No problem, I was also on a longer vacation :slight_smile:

Unfortunately, those warnings/errors about missing files (the file seem to be in the DB but not in the files folder) could lead to unexpected behaviors later :frowning: It would be best, if you could correct those warnings/errors as well – either to upload the correct files or to correctly (considering all dependencies) remove them from the DB, thus best using web UI.

Best,
Bozana


#13

Hello guys,
I got the same error in 3.1.1-4 but in line 526 of the file ReviewAssignment.inc.php

We’ve tried to run the DELETE commands mentioned before but no lines where deleted.

Does anyone have a clue?


#14

Hi @GustavoTonini

I am just working in the upgrading process from OJS 2.4.6 to 3.1.1.4 again, this time with other journal, and I got the same error. Following the help for @bozana in this topic I got accomplished the upgrading process again.

I suggest you that you review in the following tables:

±------------------------------+
| TABLE_NAME |
±------------------------------+
| article_authors |
| article_comments |
| article_files |
| article_galleys |
| article_notes |
| article_search_objects |
| article_settings |
| article_supplementary_files |
| article_xml_galleys |
| articles |
| authors |
| books_for_review |
| comments |
| dataverse_files |
| dataverse_studies |
| edit_assignments |
| edit_decisions |
| metrics |
| object_for_review_assignments |
| published_articles |
| referrals |
| review_assignments |
| review_rounds |
±------------------------------+

with a SQL query as the following:

SELECT submission_id FROM review_assignments WHERE submission_id NOT IN (SELECT article_id FROM articles);

You have to change submission_id for article_id depending the table of above.

If you find rows with the queries above, then you have to remove them from the table, however you have to find if that table isn’t connected with another table, for sample review_assignments is connected with review_form_responses, for what is important to remove in both tables that rows that its submission_id is not in the articles table. In my specific case when I run this process for my first journal, it works only removing the rows from review_form_responses, review_assignments and article_comments using the following queries:

DELETE FROM review_form_responses WHERE review_id IN (SELECT review_id FROM review_assignments WHERE submission_id NOT IN (SELECT article_id FROM articles))

DELETE FROM review_assignments WHERE submission_id NOT IN (SELECT article_id FROM articles);

DELETE FROM article_comments WHERE article_id NOT IN (SELECT article_id FROM articles);

However this time when I run the process for upgrading my second journal I had to remove other rows in the following tables;

article_comments
article_xml_galleys
authors
comments
metrics
referrals
review_rounds
review_assignments
review_form_responses

I hope this could help you.

P.D: This is very important, each time you run the upgrade.php script you have to restore your database backup and your files_dir directory, if you don’t restore the last one, when you execute the process again you will find warnings as:

WARNING: Unable to find a match for "67899-198484-1-RV.docx" in "/var/www/html/ojs3/files/journals/104//articles/67899/". Skipping this file.
WARNING: Unable to find a match for "67901-198499-1-RV.docx" in "/var/www/html/ojs3/files/journals/104//articles/67901/". Skipping this file.
WARNING: Unable to find a match for "67905-198502-1-RV.docx" in "/var/www/html/ojs3/files/journals/104//articles/67905/". Skipping this file.

PHP Warning:  assert(): Assertion failed in /var/www/html/ojs3/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 374
PHP Warning:  copy(/var/www/html/ojs3/files/journals/104//articles/56723/attachment/56723-1-162298-1-13-20160802.png): failed to open stream: No existe el fichero o el directorio in /var/www/html/ojs3/lib/pkp/classes/file/FileManager.inc.php on line 159

Best Juan Manuel (juanCure)


#15

Hi @juancure
I’ve checked all the tables mentioned above and all other tables which have submission_id/article_id columns, including article_event_log.

Even though, the same error persists. This time, it appears in the section “removeCancelledReviewAssignments” of the upgrade script.

Any help will be appreciated.