Upgrade to 3.1.1-1: Call to a member function getStatus() on null

Hello guys,
after trying to upgrade a big installation from 2.4.8-3 to 3.1.1-1 dozens of times, I came up with a different error:

PHP Fatal error: Call to a member function getStatus() on null in classes/install/Upgrade.inc.php on line 1369

I still gonna try to upgrade to 3.1.1-2 and tell you if the error persists.

The problem persists on the new version (3.1.1-2)

Hi @GustavoTonini,

It seems like you have an entry in your tables for a nonexistent article. Check e.g. to make sure that the article_id column in article_supplementary_files always refers to an existing article.

Regards,
Alec Smecher
Public Knowledge Project Team

Thank you again, @asmecher.

We added one more command to our “pre upgrade script”: delete from article_supplementary_files where article_id not in (select article_id from articles);

@asmecher The error persists even after running the following commands:

delete from article_supplementary_files where article_id not in (select article_id from articles);
delete from article_files where article_id not in (select article_id from articles);
delete from article_settings where article_id not in (select article_id from articles);
delete from submission_files where submission_id not in (select submission_id from submissions);
delete from submission_settings where submission_id not in (select submission_id from submissions);

Am I missing something?

Hi @GustavoTonini,

Do you have both articles and submissions in your database? Your OJS 2.x database should only have articles, and after upgrade, your OJS 3.x database should only have submissions. If you have both, make sure you’re dropping your database, re-creating it empty, and then reloading from backup before you run the upgrade script again.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,
We have the same problem to upgrade version.
It 's a archived article with status 0.

Do you know if the upgrade process keep in mind this status?

select * from article_files where file_id=357157;
+---------+----------+------------+------------------------+-----------------+-----------+--------------------+------+----------+---------------------+---------------------+-------+----------------+-----------------+----------+
| file_id | revision | article_id | file_name | file_type | file_size | original_file_name | type | viewable | date_uploaded | date_modified | round | source_file_id | source_revision | assoc_id |
+---------+----------+------------+------------------------+-----------------+-----------+--------------------+------+----------+---------------------+---------------------+-------+----------------+-----------------+----------+
| 357157 | 1 | 257946 | 257946-357157-1-SP.pdf | application/pdf | 439599 | 14A.pdf | supp | NULL | 2013-04-19 20:03:23 | 2013-04-19 20:03:23 | 1 | NULL | NULL | NULL |
+---------+----------+------------+------------------------+-----------------+-----------+--------------------+------+----------+---------------------+---------------------+-------+----------------+-----------------+----------+
1 row in set (0.00 sec)

mysql> select * from articles where article_id=257946;
+------------+---------+------------+------------+----------+----------------+---------------------+---------------------+----------------------+--------+---------------------+---------------+--------------------+-----------------+----------------+----------------+-------+--------+-----------+------+--------------+-------------+-----------------+
| article_id | user_id | journal_id | section_id | language | comments_to_ed | date_submitted | last_modified | date_status_modified | status | submission_progress | current_round | submission_file_id | revised_file_id | review_file_id | editor_file_id | pages | locale | citations | doi | fast_tracked | hide_author | comments_status |
+------------+---------+------------+------------+----------+----------------+---------------------+---------------------+----------------------+--------+---------------------+---------------+--------------------+-----------------+----------------+----------------+-------+--------+-----------+------+--------------+-------------+-----------------+
| 257946 | 51 | 284 | 0 | spa | NULL | 2012-09-14 20:02:24 | 2017-11-23 09:39:06 | 2017-11-23 09:39:06 | 0 | 0 | 1 | NULL | NULL | NULL | NULL | 7-12 | ca_ES | NULL | NULL | 0 | 0 | 0 |
+------------+---------+------------+------------+----------+----------------+---------------------+---------------------+----------------------+--------+---------------------+---------------+--------------------+-----------------+----------------+----------------+-------+--------+-----------+------+--------------+-------------+-----------------+

I checked in my database from the error reported in my log:

 SELECT * FROM genre_settings WHERE genre_id = '1896' 
   
-----<hr>
-----<hr>
(mysql): SELECT DISTINCT
				sf.file_id AS submission_file_id, sf.revision AS submission_revision,
				af.file_id AS artwork_file_id, af.revision AS artwork_revision,
				suf.file_id AS supplementary_file_id, suf.revision AS supplementary_revision,
				s.locale AS submission_locale,
				sf.*, af.*, suf.*
			FROM	submission_files sf
				LEFT JOIN submission_artwork_files af ON sf.file_id = af.file_id AND sf.revision = af.revision
				LEFT JOIN submission_supplementary_files suf ON sf.file_id = suf.file_id AND sf.revision = suf.revision
				LEFT JOIN submissions s ON s.submission_id = sf.submission_id WHERE  sf.file_id = 357157 ORDER BY sf.submission_id ASC, sf.file_stage ASC, sf.file_id ASC, sf.revision DESC 
   
-----<hr>
-----<hr>
(mysql): SELECT * FROM submission_file_settings WHERE file_id = '357157' 
   
-----<hr>
PHP Fatal error:  Call to a member function getStatus() on null in ojs/classes/install/Upgrade.inc.php on line 1369

Fatal error: Call to a member function getStatus() on null in ojs/classes/install/Upgrade.inc.php on line 1369

Regards,
xavi.

Buenos dĂ­as, tengo el mismo problema al actualizar desde la versiĂłn 2.4.8-3 a la versiĂłn 3.1.1-2:
PHP Fatal error: Call to a member function getStatus() on null in classes/install/Upgrade.inc.php on line 1369.
En la nueva base se creĂł la tabla “submission” y se eliminĂł la tabla “articles”. Creo que el problema esta en tabla origina articles, en la columna status cuando el valor es 0. Se lo modifiquĂ© para probar, y realizĂł mas lineas de actualizaciĂłn y luego me volviĂł a mostrar el mismo mensaje. Saludos

Hello everyone
I have the same problem of upgrading from version 2.8.4-3 to version 3.1.1-2:

PHP Fatal error: Call to a member function getStatus() on null in /var/www/html/seer/classes/install/Upgrade.inc.php on line 1369

I’m using PHP version 5.6.37 and running the upgrade via cli on a test server.
Has anyone figured out how to solve this problem?

The error occurred due to the existence of null value records in the “section_id” field of the OJS 2.4.8-3 “articles” table. The update ran correctly after correcting this problem.

1 Like

Buenas tardes, cuando intentaba actualizar se producía el mismo error. En la base de datos había un error en la columna file_id=799 de la tabla articles_files, eliminando esa fila y las filas de tablas donde se encontraba el registro con file_id igual a 799 pude actualizar correctamente. Creo que en cada caso particular hay que encontrar la inconsistencia en la base de datos. Por lo tanto la mejor opción es configurar en config.inc.php la base de datos en modo debug, y muestra todas las sentencias sql que se van ejecuntando. De esa manera encontré el error, saludos

The solution for this issue was to look at the tables “articles” and “submissions” for records with section_id=null or section_id=0. Then, after fixing the articles’ sections (or simply deleting them), the upgrade process passed this point.

What is “existing article”? When an article is deleted (in OJS 2, by clicking in as Journal Editor, and clicking to Archives and deleting from there; not just removing from any issues), the software keeps a record of that article. That’s to allow tombstones in OAI-PMH, and keep a record that it existed maybe in case of anyone wanting to check on submissions as a whole.

If an article has been deleted from OJS 2, then would that cause this same problem? If so, how can the problem be fixed?

-Wilhelmina

Hi @randtke,

When you delete an article, it does leave a tombstone – but it should be fully removed from the articles table and other related tables (e.g. article_supplementary_files).

Regards,
Alec Smecher
Public Knowledge Project Team

What log file were you using to find out the upgrade error report? Did you use any argument in command line to get it log with detail information when you run upgrade.php? At least if I also want error report being logged, what shall I do?

Thank you.

Hi Liang, you need to activate log in your config.inc.php (ojs)

  • ; Enable database debug output (very verbose!)
    debug = On

  • ; Display execution stats in the footer
    show_stats = On

  • ; Display a stack trace when a fatal error occurs.
    ; Note that this may expose private information and should be disabled
    ; for any production system.
    show_stacktrace = On

  • ; Display an error message when something goes wrong.
    display_errors = On

If you are running in a virtual machine or with connection by ssh, maybe you need to use ‘nohup’ command:

cd /ojs
nohup php tools/upgrade.php upgrade &

Regards.

Thank you very much, will try it out.

Alec,

I have one article with a NULL section_id where I can’t get to it through the web interface. So, I go to the journal it’s in, and then I try to pull it up from “Editor” “Archives” or directly by URL like domainhere/journalcodehere/editor/submission/articlenumberhere and I can’t get to it.

In this case, how can I handle this one article?

Directly in the database, delete the row from the articles table?
Directly in the database, change the section_id to match the section_id of any other article within the same journal?

What is a way to handle this without causing a data integrity problem?

Best,

-Wilhelmina

Hi @randtke,

I’d suggest setting the section_id to an existing entry in the sections table.

Regards,
Alec Smecher
Public Knowledge Project Team