Upgrade to OJS 3.0 from 2.4.8.0 - Error while converting supplementary files

Hi,

I’m testing upgrade again.
But now I got a new error:

[pre-install]
[load: upgrade.xml]
[version: 3.0.0.0]

[code: Installer Installer::syncSeriesAssocType]
[data: dbscripts/xml/upgrade/2.4.0_preupdate_usageStatistics.xml (skipped)]
[data: dbscripts/xml/upgrade/2.4.0_preupdate_usageStatistics2.xml]
[data: dbscripts/xml/upgrade/3.0.0_preupdate.xml]
[data: dbscripts/xml/upgrade/3.0.0_adaptTimedViews.xml (skipped)]
[data: dbscripts/xml/upgrade/3.0.0_adaptReferrals.xml]
[data: dbscripts/xml/upgrade/3.0.0_adaptBooksForReview.xml]
[schema: lib/pkp/xml/schema/common.xml]
[schema: lib/pkp/xml/schema/log.xml]
[schema: lib/pkp/xml/schema/announcements.xml]
[schema: lib/pkp/xml/schema/scheduledTasks.xml]
[schema: lib/pkp/xml/schema/temporaryFiles.xml]
[schema: lib/pkp/xml/schema/metadata.xml]
[schema: lib/pkp/xml/schema/reviews.xml]
[schema: lib/pkp/xml/schema/reviewForms.xml]
[schema: lib/pkp/xml/schema/controlledVocab.xml]
[schema: lib/pkp/xml/schema/submissions.xml]
[schema: lib/pkp/xml/schema/submissionFiles.xml]
[schema: lib/pkp/xml/schema/notes.xml]
[schema: lib/pkp/xml/schema/views.xml]
[schema: lib/pkp/xml/schema/genres.xml]
[schema: lib/pkp/xml/schema/gifts.xml]
[schema: lib/pkp/xml/schema/mutex.xml]
[schema: lib/pkp/xml/schema/tombstone.xml]
[schema: lib/pkp/xml/schema/rolesAndUserGroups.xml]
[schema: lib/pkp/xml/schema/metrics.xml]
[schema: lib/pkp/xml/schema/views.xml]
[schema: lib/pkp/xml/schema/libraryFiles.xml]
[schema: dbscripts/xml/ojs_schema.xml]
[data: dbscripts/xml/indexes.xml]
[data: dbscripts/xml/upgrade/3.0.0_change_assoc_type.xml]
[data: dbscripts/xml/upgrade/3.0.0_change_assoc_type_metrics.xml]
[data: dbscripts/xml/upgrade/3.0.0_settings.xml]

[code: Installer Installer::migrateArticleMetadata]
[data: dbscripts/xml/upgrade/3.0.0_update.xml]

[code: Installer Installer::clearDataCache]

[code: Installer Installer::migrateUserRoles]

[code: Installer Installer::installDefaultGenres]
[data: dbscripts/xml/upgrade/remove_timed_views_bots.xml (skipped)]

[code: Installer Installer::migrateCounterPluginUsageStatistics (skipped)]

[code: Installer Installer::migrateTimedViewsUsageStatistics (skipped)]

[code: Installer Installer::migrateDefaultUsageStatistics (skipped)]
[data: dbscripts/xml/upgrade/2.4.0_postUsageStatsMigration.xml (skipped)]
[data: dbscripts/xml/upgrade/2.4.0_postUsageStatsMigration2.xml]
[data: dbscripts/xml/upgrade/2.4.0_postCounterMigration.xml (skipped)]
[data: dbscripts/xml/upgrade/2.4.0_postTimedViewsMigration.xml (skipped)]

[code: Installer Installer::fixReviewForms]

[code: Installer Installer::htmlifyEmailTemplates]
[note: docs/release-notes/README-BEACON]

[code: Installer Installer::installEmailTemplate]

[code: Installer Installer::installEmailTemplate]

[code: Installer Installer::installEmailTemplate]

[code: Installer Installer::installEmailTemplate]

[code: Installer Installer::installEmailTemplate]
[data: dbscripts/xml/upgrade/3.0.0_scheduledTasks.xml]

[code: Installer Installer::localizeCustomBlockSettings]

[code: Installer Installer::convertEditorDecisionNotes]

[code: Installer Installer::convertQueries]

[code: Installer Installer::migrateFiles]

[code: Installer Installer::convertSupplementaryFiles]
PHP Fatal error: Call to a member function getId() on null in […/]ojs3/classes/install/Upgrade.inc.php on line 936

Can someone help me?

Hi @Tarcisio_Pereira,

Is there a reason you’re not using OJS 3.0.1? I’d suggest working with that version if possible – it contains numerous fixes for OJS 3.0.0 issues.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher

I will try.
Regards,

Tarcisio Pereira

Hi @asmecher

Same problem with 3.0.1.0 too.

Regards,
Tarcisio Pereira.

Hi,

No errors in postgresql logs.
I have no idea.

Regards,
Tarcisio Pereira

Hi @Tarcisio_Pereira,

Is it possible that you have a journal with no Journal Managers registered within it?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher

No, I checked with this command:

select distinct journal_id from roles where role_id = 16 order by journal_id;
All journals are listed.

Maybe some leftjoin are retrieving null_id?

Regards,
Tarcisio Pereira.

Hi @Tarcisio_Pereira,

That shows that all journals have a Journal Manager role, but not that there are users assigned to it.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher

If I’m not wrong, my select will list any journal with one or more entries with role_id = 16 (OJS 2.4.8.0).
It’s supposed to work fine if OJS only input a full entry (user_id too), isn’t? Maybe I’m missing something.
Anyway, I double check with other query:

select journal_id, role_id, count(user_id)
from roles
where role_id = 16
and user_id is not null
group by journal_id, role_id
order by journal_id;

All journals and total count of Journal Managers are listed:

1,16,1
2,16,1
3,16,4
4,16,2
5,16,1
6,16,3
7,16,2
8,16,4
9,16,6
10,16,1
11,16,4
12,16,2
13,16,4
14,16,2
15,16,1
16,16,4
17,16,3
18,16,6
19,16,4
22,16,1
23,16,1
24,16,2
25,16,2
26,16,2
27,16,5
28,16,3
29,16,2
30,16,1
31,16,2
32,16,2
33,16,2
34,16,4
35,16,2
36,16,6
37,16,1
38,16,1
39,16,5
40,16,1
43,16,8
44,16,3
45,16,5
46,16,7
47,16,5
48,16,6
49,16,2
50,16,2
51,16,1
52,16,4
53,16,5
54,16,4
55,16,1
56,16,6
57,16,6
58,16,5
59,16,4
60,16,7
61,16,3
62,16,2
63,16,5
64,16,5
65,16,4
66,16,8
67,16,3
68,16,5
69,16,5
70,16,4
71,16,11
72,16,3
74,16,4
75,16,2
76,16,2
77,16,3
78,16,2
79,16,3
80,16,7
81,16,9
82,16,1
84,16,5
85,16,4
86,16,5
87,16,2
88,16,3
89,16,7
90,16,3
91,16,10
92,16,7
93,16,3
94,16,4
95,16,3
96,16,7
97,16,7
98,16,5
99,16,5
100,16,5
101,16,7
102,16,3
103,16,3
104,16,3
105,16,3
106,16,3
107,16,3
108,16,9
109,16,15
110,16,5
111,16,10
112,16,6
113,16,6
114,16,6
115,16,6
116,16,15
117,16,5
118,16,6
119,16,5
120,16,4
121,16,1
122,16,4
123,16,4
124,16,3
125,16,3
126,16,2
127,16,2
128,16,14
129,16,3
130,16,4
131,16,10
132,16,1
133,16,10
134,16,5
135,16,11
137,16,4
138,16,1
139,16,2
140,16,7
141,16,4
142,16,2
143,16,4
144,16,3
145,16,7
146,16,5
147,16,6
148,16,6
149,16,3
150,16,5
151,16,3
152,16,2
153,16,6
154,16,11
155,16,2
156,16,2
157,16,6
158,16,6
159,16,1
160,16,3
161,16,5
162,16,2
163,16,2
164,16,2
165,16,5
166,16,4
167,16,5
168,16,6
169,16,2
170,16,2
171,16,2
177,16,1
179,16,2
180,16,2
181,16,5
182,16,5
183,16,8
184,16,2
185,16,2
186,16,3
187,16,2
188,16,31
189,16,2
190,16,4
191,16,2
192,16,2
193,16,4
194,16,3
195,16,13
196,16,3
197,16,2
198,16,2
199,16,2
200,16,2
201,16,2
202,16,3
203,16,2
204,16,3
205,16,3
206,16,5
207,16,8
208,16,2
209,16,2
210,16,2
211,16,2
212,16,2
213,16,2
214,16,2
215,16,2
216,16,1
217,16,10
218,16,3
219,16,5
220,16,2
221,16,9
222,16,3
223,16,3
224,16,3

Regards,
Tarcisio Pereira.

Hi @Tarcisio_Pereira,

Perhaps some of your journal entries have been deleted, but I don’t see all contiguous journal_ids listed – see e.g. journal_id = 20, 21.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi Alec!

Yes, we have 211 journals, but not contiguous journal_id.
Sometimes we create temporary journal for test or training purposes.

Regards,

Tarcisio Pereira.

Hi @asmecher

Take a look:

select a.article_id as “ID FROM ARTICLE”, af.article_id “ID FROM ARTICLE FILES”, * from article_files af left join articles a on (af.article_id = a.article_id) where af.file_stage = 6 and (a.article_id is null or af.article_id is null);
Number of records: 23

23 supplementary files without the real article.

Regards,
Tarcisio Pereira.

After deleting those 23 files without real article:

[code: Installer Installer::convertSupplementaryFiles]
PHP Fatal error: Call to a member function getId() on null in /var/www/html/ojs3/classes/install/Upgrade.inc.php on line 1017
Other line.

PostgreSQL LOG:

LOG:  execute <unnamed>: SELECT DISTINCT u.*
				FROM	users AS u
					LEFT JOIN user_settings us ON (us.user_id = u.user_id AND us.setting_name = 'affiliation')
					LEFT JOIN user_interests ui ON (u.user_id = ui.user_id)
					LEFT JOIN controlled_vocab_entry_settings cves ON (ui.controlled_vocab_entry_id = cves.controlled_vocab_entry_id)
					LEFT JOIN user_user_groups uug ON (uug.user_id = u.user_id)
					LEFT JOIN user_groups ug ON (ug.user_group_id = uug.user_group_id)
				WHERE	1=1 AND ug.context_id =  $1 AND ug.user_group_id =  $2 ORDER BY u.last_name, u.first_name
DETAIL:  parameters: $1 = '195', $2 = '497'

Hi @Tarcisio_Pereira,

Just to double-check, this query would list all journal_ids where no Journal Manager roles were present:

 SELECT j.journal_id FROM journals j LEFT JOIN roles r ON (r.role_id=16 AND r.journal_id=j.journal_id) WHERE r.role_id IS NULL;

Can you verify what line 1017 looks like in classes/install/Upgrade.inc.php?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher

ojs=> SELECT j.journal_id FROM journals j LEFT JOIN roles r ON (r.role_id=16 AND r.journal_id=j.journal_id) WHERE r.role_id IS NULL;
journal_id

(0 rows)

Upgrade.inc.php

1010 while (!$suppFilesResult->EOF) {
1011 $row = $suppFilesResult->getRowAssoc(false);
1012 $suppFilesResult->MoveNext();
1013 if (!$journal || $journal->getId() != $row[‘context_id’]) {
1014 $journal = $journalDao->getById($row[‘context_id’]);
1015 $managerUserGroup = $userGroupDao->getDefaultByRoleId($journal->getId(), ROLE_ID_MANAGER);
1016 $managerUsers = $userGroupDao->getUsersById($managerUserGroup->getId(), $journal->getId());
1017 $creatorUserId = $managerUsers->next()->getId();
1018 }
1019 $article = $articleDao->getById($row[‘article_id’]);

Some missing user?

Regards,
Tarcisio Pereira.

Hi @Tarcisio_Pereira,

Let’s try…

 SELECT j.journal_id, r.user_id FROM journals j JOIN roles r ON (r.role_id=16 AND r.journal_id=j.journal_id) LEFT JOIN users u ON (u.user_id = r.user_id) WHERE u.user_id IS NULL;

If you see any entries, then it’ll be an entry in roles that refers to an entry in users that no longer exists. If you find these, remove them from roles and it should get you past that upgrade situation.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher

ojs=> SELECT j.journal_id, r.user_id FROM journals j JOIN roles r ON (r.role_id=16 AND r.journal_id=j.journal_id) LEFT JOIN users u ON (u.user_id = r.user_id) WHERE u.user_id IS NULL;
journal_id | user_id
------------±--------
(0 rows)

No entries.
It’s a bizarre error, isn’t?

Regards,
Tarcisio Pereira

Hi @Tarcisio_Pereira,

Hmm. Above, you quoted the following PostgreSQL query:

LOG:  execute <unnamed>: SELECT DISTINCT u.*
	FROM	users AS u
		LEFT JOIN user_settings us ON (us.user_id = u.user_id AND us.setting_name = 'affiliation')
		LEFT JOIN user_interests ui ON (u.user_id = ui.user_id)
		LEFT JOIN controlled_vocab_entry_settings cves ON (ui.controlled_vocab_entry_id = cves.controlled_vocab_entry_id)
		LEFT JOIN user_user_groups uug ON (uug.user_id = u.user_id)
		LEFT JOIN user_groups ug ON (ug.user_group_id = uug.user_group_id)
	WHERE	1=1 AND ug.context_id =  $1 AND ug.user_group_id =  $2 ORDER BY u.last_name, u.first_name
DETAIL:  parameters: $1 = '195', $2 = '497'

This indicates that OJS is looking for any users in the journal_id 195 and user group 497 (which is the default managers user group). It’s finding no users there, though your previous query indicates that there are managers for that journal.

Is it possible that you’re running the upgrade on a database that already has a user_groups table lying around from a previous upgrade? I wonder if the roles information was already partially (but not completely) migrated during a previous upgrade attempt, and the table was left around. Make sure to DROP the database entirely before reloading from backup.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher

No, it’s not possible. I always drop it before restore.
Anyway, I will drop it again and restore a OJS 2.4.8.0 backup to test again.
I will take a look in user_groups to check for missing information.
I will post here my results when I’m done.

Regards,
Tarcisio Pereira.

Hi @asmecher

Manually query:

ojs=> SELECT DISTINCT u.* FROM users AS u LEFT JOIN user_settings us ON (us.user_id = u.user_id AND us.setting_name = ‘affiliation’) LEFT JOIN user_interests ui ON (u.user_id = ui.user_id) LEFT JOIN controlled_vocab_entry_settings cves ON (ui.controlled_vocab_entry_id = cves.controlled_vocab_entry_id) LEFT JOIN user_user_groups uug ON (uug.user_id = u.user_id) LEFT JOIN user_groups ug ON (ug.user_group_id = uug.user_group_id) WHERE 1=1 AND ug.context_id = 195 AND ug.user_group_id = 497 ORDER BY u.last_name, u.first_name;
user_id | username | password | salutation | first_name | middle_name | last_name | suffix | gend
er | initials | email | url | phone | mailing_address | billing_address | country | locales | date
_last_email | date_registered | date_validated | date_last_login | must_change_password | auth_id
| auth_str | disabled | disabled_reason | inline_help
---------±---------±---------±-----------±-----------±------------±----------±-------±----
—±---------±------±----±------±----------------±----------------±--------±--------±----
------------±----------------±---------------±----------------±---------------------±--------
±---------±---------±----------------±------------
(0 rows)

First check:

ojs=> select * from user_groups where context_id = 195 AND user_group_id = 497;
user_group_id | context_id | role_id | is_default | show_title | permit_self_registration
---------------±-----------±--------±-----------±-----------±-------------------------
497 | 195 | 16 | 1 | 0 | 0
(1 row)

Other one:

ojs=> select * from user_groups where context_id = 195 and role_id = 16;
user_group_id | context_id | role_id | is_default | show_title | permit_self_registration
---------------±-----------±--------±-----------±-----------±-------------------------
497 | 195 | 16 | 1 | 0 | 0
496 | 195 | 16 | 1 | 0 | 0
495 | 195 | 16 | 1 | 0 | 0
(3 rows)

And finally:

ojs=> select * from user_user_groups where user_id=1 and user_group_id in (495, 496, 497) order by user_group_id;
user_group_id | user_id
---------------±--------
495 | 1
496 | 1
(2 rows)

If I understood, I really have a group with no one inside.
But the real question is: Why?
This journal have 13 Editors Managers.

Regards,
Tarcisio Pereira.