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

Hi @asmecher

I deleted all entries in article_supplementary_files with no real article_files.
But now:

[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 1020

And in Upgrade.inc.php

$suppFilesResult = $submissionFileDao->retrieve(‘SELECT a.context_id, sf.* FROM article_supplementary_files sf,
submissions a WHERE a.submission_id = sf.ar ticle_id’); // COMMENT_TYPE_EDITOR_DECISION
1013 while (!$suppFilesResult->EOF) {
1014 $row = $suppFilesResult->getRowAssoc(false);
1015 $suppFilesResult->MoveNext();
1016 if (!$journal || $journal->getId() != $row[‘context_id’]) {
1017 $journal = $journalDao->getById($row[‘context_id’]);
1018 $managerUserGroup = $userGroupDao->getDefaultByRoleId($journal->getId(), ROLE_ID_MANAGER);
1019 $managerUsers = $userGroupDao->getUsersById($managerUserGroup->getId(), $journal->getId());
1020 $creatorUserId = $managerUsers->next()->getId();
1021 }
1022 $article = $articleDao->getById($row[‘article_id’]);

Last postgre log:

LOG: execute : 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 = ‘218’, $2 = ‘157’

Manually executing the query:

(0 rows)

The whole story seems endless madness. Looks like user migration problem again.

Regards,
Tarcisio Pereira.

Hi @Tarcisio_Pereira

Could it be that your journal = 218 does not have any journal manager? – It is not enough to have admin user with journal manager rights, but a ‘real’ journal manager user.

Best,
Bozana

Hi @bozana

Yes, I had 19 journals that the admin user was the only journal manager.
Now all journals have a ‘real’ user as journal manager.
But, this error still remains.

What else can I do or check to solve this problem?

Regards,
Tarcisio Pereira.

Hi @Tarcisio_Pereira

Hmmm… for a reason the script could not found the journal manager :frowning: Could you see what is the role_id where user_group_id = 157 in the DB table user_groups? And is there a user_id with the user_group_id = 157 in the DB table user_user_groups?

Best,
Bozana

Hi @bozana

First:

select * from user_groups where user_group_id = 157;
user_group_id | context_id | role_id | is_default | show_title | permit_self_registration
---------------±-----------±--------±-----------±-----------±-------------------------
157 | 218 | 16 | 1 | 0 | 0
(1 row)

Second:

select * from user_user_groups where user_group_id = 157;
user_group_id | user_id
---------------±--------
(0 rows)

Bonus:

select * from user_groups where user_group_id in (155, 156, 157);
user_group_id | context_id | role_id | is_default | show_title | permit_self_registration
---------------±-----------±--------±-----------±-----------±-------------------------
155 | 218 | 16 | 1 | 0 | 0
156 | 218 | 16 | 1 | 0 | 0
157 | 218 | 16 | 1 | 0 | 0
(3 rows)

and:

select * from user_user_groups where user_group_id in (155, 156, 157);
user_group_id | user_id
---------------±--------
155 | 52962
155 | 42397
155 | 1
156 | 52962
156 | 42397
(5 rows)

Same thing on:

Regards,
Tarcisio Pereira.

Hmmm… I am not sure about your very last displays – if this has something to do with that error… it seems to be something with editors… Thus, I will take a look at that a little bit later, after we figured out what is wrong with the journal manager for the journal 218. Could you please take a look in your old DB table roles and see if there is a user_id where role_id = 16 and journal_id = 218 and also if there is a user_id with role_id = 16 for each journal_id in this DB table?
EDIT: And one more thing: what is the setting_value from the new DB table user_group_settings, where user_group_id = 157 and setting_name = ‘name’?

155, 156 and 157 should be manger, editor and productionEditor. I just wonder how come 157 is a manager – it is usually on the first place i.e. it should be 155… Hmmm…

Thanks!!!

Hi @bozana

select * from roles where role_id = 16 and journal_id = 218;
journal_id | user_id | role_id
------------±--------±--------
218 | 1 | 16
218 | 42397 | 16
218 | 52962 | 16
(3 rows)

Both no admin users really exists in users tables.[quote=“bozana, post:46, topic:25950”]
see if there is a user_id where role_id = 16 and journal_id = 218 and also if there is a user_id with role_id = 16 for each journal_id in this DB table?
[/quote]

I’ve done this check a few times and checked again now to be sure. There is at last one no admin user with role_id = 16 to each one.

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

We have 214 journals in journals table;

select * from user_group_settings where user_group_id = 157 and setting_name = ‘name’;
user_group_id | locale | setting_name | setting_value | setting_type
---------------±-------±-------------±-----------------------------------------±-------------
157 | de_DE | name | ##default.groups.name.productionEditor## | string
157 | en_US | name | ##default.groups.name.productionEditor## | string
157 | es_ES | name | ##default.groups.name.productionEditor## | string
157 | fr_CA | name | ##default.groups.name.productionEditor## | string
157 | fr_FR | name | ##default.groups.name.productionEditor## | string
157 | it_IT | name | ##default.groups.name.productionEditor## | string
157 | ja_JP | name | ##default.groups.name.productionEditor## | string
157 | pt_BR | name | Editor de produção | string
157 | ru_RU | name | ##default.groups.name.productionEditor## | string
(9 rows)

Thank you! a lot!

Hi @Tarcisio_Pereira

Hmmm… the error says the line 1020, which is, like you said:

1018 $managerUserGroup = $userGroupDao->getDefaultByRoleId($journal->getId(), ROLE_ID_MANAGER);
1019 $managerUsers = $userGroupDao->getUsersById($managerUserGroup->getId(), $journal->getId());
1020 $creatorUserId = $managerUsers->next()->getId();
1021 }
1022 $article = $articleDao->getById($row[‘article_id’]);

Would it be possible for you to somehow debug and find/print out what are $managerUserGroup, $journal->getId() and $managerUsers there? It is in the function convertSupplementaryFiles, in classes/install/Upgrade.inc.php.

I wonder why is your last PostgreSQL query log the one searching for editors, probably from the function migrateUserRoles – because there are lots of other functions between the function migrateUserRoles and convertSupplementaryFiles, s. https://github.com/pkp/ojs/blob/ojs-3_0_2-0/dbscripts/xml/upgrade.xml#L84-L100.
My fault, I thought it has something to do with this error your are getting :-
That’s why I would like to fist stay on those lines where this error occurs and figure that out…

Maybe also to print out what is happening here: https://github.com/pkp/ojs/blob/ojs-3_0_2-0/classes/install/Upgrade.inc.php#L248-L254 – to be sure all old journal managers are assigned to the right group…

Thanks!
Bozana

Hi @bozana

Probably because of line 1019:[quote=“bozana, post:48, topic:25950”]
1019 $managerUsers = $userGroupDao->getUsersById($managerUserGroup->getId(), $journal->getId());
[/quote]

My debug code:

1013 while (!$suppFilesResult->EOF) {
1014 $row = $suppFilesResult->getRowAssoc(false);
1015 $suppFilesResult->MoveNext();
1016 if (!$journal || $journal->getId() != $row[‘context_id’]) {
1017 $journal = $journalDao->getById($row[‘context_id’]);
1018 $managerUserGroup = $userGroupDao->getDefaultByRoleId($journa l->getId(), ROLE_ID_MANAGER);
1019 $managerUsers = $userGroupDao->getUsersById($managerUserGroup ->getId(), $journal->getId());
1020 echo(‘journal_id=’.$journal->getId().’ managerUserGroup_id='.$managerUserGroup->getId().“\n”);
1021 if($journal->getId() == 218){
1022 var_dump($managerUserGroup);
1023 var_dump($managerUsers);
1024 }
1025 $creatorUserId = $managerUsers->next()->getId();
1026 }
1027 $article = $articleDao->getById($row[‘article_id’]);

And, my results (journal_id=218 only):

journal_id=218 managerUserGroup_id=157
object(UserGroup)#87561 (6) {
[“_data”]=>
array(10) {
[“id”]=>
string(3) “157”
[“roleId”]=>
string(2) “16”
[“contextId”]=>
string(3) “218”
[“isDefault”]=>
string(1) “1”
[“showTitle”]=>
string(1) “0”
[“permitSelfRegistration”]=>
string(1) “0”
[“abbrevLocaleKey”]=>
string(38) “default.groups.abbrev.productionEditor”
[“nameLocaleKey”]=>
string(36) “default.groups.name.productionEditor”
[“abbrev”]=>
array(9) {
[“de_DE”]=>
string(42) “##default.groups.abbrev.productionEditor##”
[“en_US”]=>
string(42) “##default.groups.abbrev.productionEditor##”
[“es_ES”]=>
string(42) “##default.groups.abbrev.productionEditor##”
[“fr_CA”]=>
string(42) “##default.groups.abbrev.productionEditor##”
[“fr_FR”]=>
string(42) “##default.groups.abbrev.productionEditor##”
[“it_IT”]=>
string(42) “##default.groups.abbrev.productionEditor##”
[“ja_JP”]=>
string(42) “##default.groups.abbrev.productionEditor##”
[“pt_BR”]=>
string(2) “EP”
[“ru_RU”]=>
string(42) “##default.groups.abbrev.productionEditor##”
}
[“name”]=>
array(9) {
[“de_DE”]=>
string(40) “##default.groups.name.productionEditor##”
[“en_US”]=>
string(40) “##default.groups.name.productionEditor##”
[“es_ES”]=>
string(40) “##default.groups.name.productionEditor##”
[“fr_CA”]=>
string(40) “##default.groups.name.productionEditor##”
[“fr_FR”]=>
string(40) “##default.groups.name.productionEditor##”
[“it_IT”]=>
string(40) “##default.groups.name.productionEditor##”
[“ja_JP”]=>
string(40) “##default.groups.name.productionEditor##”
[“pt_BR”]=>
string(20) “Editor de produção”
[“ru_RU”]=>
string(40) “##default.groups.name.productionEditor##”
}
}
[“_hasLoadableAdapters”]=>
bool(false)
[“_metadataExtractionAdapters”]=>
array(0) {
}
[“_extractionAdaptersLoaded”]=>
bool(false)
[“_metadataInjectionAdapters”]=>
array(0) {
}
[“_injectionAdaptersLoaded”]=>
bool(false)
}
object(DAOResultFactory)#88612 (10) {
[“dao”]=>
&object(UserDAO)#305 (1) {
[“_dataSource”]=>
object(ADODB_postgres7)#30 (94) {
[“databaseType”]=>
string(9) “postgres7”
[“hasLimit”]=>
bool(true)
[“ansiOuter”]=>
bool(true)
[“charSet”]=>
string(4) “UTF8”
[“metaColumnsSQL”]=>
string(970) “SELECT a.attname,
CASE
WHEN x.sequence_name != ‘’ THEN ‘SERIAL’
ELSE t.typname
END AS typname,
a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,a.attnum
FROM pg_class c, pg_attribute a
JOIN pg_type t ON a.atttypid = t.oid
LEFT JOIN
(SELECT c.relname as sequence_name,
c1.relname as related_table,
a.attname as related_column
FROM pg_class c
JOIN pg_depend d ON d.objid = c.oid
LEFT JOIN pg_class c1 ON d.refobjid = c1.oid
LEFT JOIN pg_attribute a ON (d.refobjid, d.refobjsubid) = (a.attrelid, a.attnum)
WHERE c.relkind = ‘S’ AND c1.relname = ‘%s’) x
ON x.related_column= a.attname
WHERE c.relkind in (‘r’,‘v’) AND
(c.relname=‘%s’ or c.relname = lower(‘%s’)) AND
a.attname not like ‘…%%’ AND
a.attnum > 0 AND
a.attrelid = c.oid
ORDER BY a.attnum”
[“metaColumnsSQL1”]=>
string(1056) "
SELECT a.attname,
CASE
WHEN x.sequence_name != ‘’ THEN ‘SERIAL’
ELSE t.typname
END AS typname,
a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, a.attnum
FROM pg_class c, pg_namespace n, pg_attribute a
JOIN pg_type t ON a.atttypid = t.oid
LEFT JOIN
(SELECT c.relname as sequence_name,
c1.relname as related_table,
a.attname as related_column
FROM pg_class c
JOIN pg_depend d ON d.objid = c.oid
LEFT JOIN pg_class c1 ON d.refobjid = c1.oid
LEFT JOIN pg_attribute a ON (d.refobjid, d.refobjsubid) = (a.attrelid, a.attnum)
WHERE c.relkind = ‘S’ AND c1.relname = ‘%s’) x
ON x.related_column= a.attname
WHERE c.relkind in (‘r’,‘v’) AND (c.relname=‘%s’ or c.relname = lower(‘%s’))
AND c.relnamespace=n.oid and n.nspname=‘%s’
AND a.attname not like ‘…%%’ AND a.attnum > 0
AND a.atttypid = t.oid AND a.attrelid = c.oid
ORDER BY a.attnum"
[“dataProvider”]=>
string(8) “postgres”
[“hasInsertID”]=>
bool(true)
[“_resultid”]=>
resource(10257562) of type (pgsql result)
[“concat_operator”]=>
string(2) “||”
[“metaDatabasesSQL”]=>
string(89) “select datname from pg_database where datname not in (‘template0’,‘template1’) order by 1”
[“metaTablesSQL”]=>
string(249) “select table_name,‘T’ from information_schema.tables where table_schema not in ( ‘pg_catalog’,‘information_schema’)
union
select table_name,‘V’ from information_schema.views where table_schema not in ( ‘pg_catalog’,‘information_schema’) "
[“isoDates”]=>
bool(true)
[“sysDate”]=>
string(12) “CURRENT_DATE”
[“sysTimeStamp”]=>
string(17) “CURRENT_TIMESTAMP”
[“blobEncodeType”]=>
string(1) “C”
[“metaKeySQL”]=>
string(484) “SELECT ic.relname AS index_name, a.attname AS column_name,i.indisunique AS unique_key, i.indisprimary AS primary_key
FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a WHERE bc.oid = i.indrelid AND ic.oid = i.indexrelid AND (i.indkey[0] = a.attnum OR i.indkey[1] = a.attnum OR i.indkey[2] = a.attnum OR i.indkey[3] = a.attnum OR i.indkey[4] = a.attnum OR i.indkey[5] = a.attnum OR i.indkey[6] = a.attnum OR i.indkey[7] = a.attnum) AND a.attrelid = bc.oid AND bc.relname = ‘%s’”
[“hasAffectedRows”]=>
bool(true)
[“true”]=>
string(1) “1”
[“false”]=>
string(1) “0”
[“fmtDate”]=>
string(7) “‘Y-m-d’”
[“fmtTimeStamp”]=>
string(13) “‘Y-m-d H:i:s’”
[“hasMoveFirst”]=>
bool(true)
[“hasGenID”]=>
bool(true)
[”_genIDSQL"]=>
string(20) “SELECT NEXTVAL(‘%s’)”
[“_genSeqSQL”]=>
string(27) “CREATE SEQUENCE %s START %s”
[“_dropSeqSQL”]=>
string(16) “DROP SEQUENCE %s”
[“metaDefaultsSQL”]=>
string(125) “SELECT d.adnum as num, d.adsrc as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname=‘%s’ order by d.adnum”
[“random”]=>
string(8) “random()”
[“autoRollback”]=>
bool(true)
[“uniqueIisR”]=>
bool(true)
[“_bindInputArray”]=>
bool(true)
[“disableBlobs”]=>
bool(false)
[“pnum"]=>
int(0)
[“database”]=>
string(4) “ojs3”
[“host”]=>
string(9) “localhost”
[“user”]=>
string(8) “revistas”
[“password”]=>
string(10) “not stored”
[“debug”]=>
bool(false)
[“maxblobsize”]=>
int(262144)
[“substr”]=>
string(6) “substr”
[“length”]=>
string(6) “length”
[“upperCase”]=>
string(5) “upper”
[“replaceQuote”]=>
string(2) “'”
[“nameQuote”]=>
string(1) “”"
[“uniqueOrderBy”]=>
bool(false)
[“emptyDate”]=>
string(6) " "
[“emptyTimeStamp”]=>
string(6) " "
[“lastInsID”]=>
bool(false)
[“hasTop”]=>
bool(false)
[“readOnly”]=>
bool(false)
[“hasTransactions”]=>
bool(true)
[“genID”]=>
int(0)
[“raiseErrorFn”]=>
bool(false)
[“cacheSecs”]=>
int(3600)
[“memCache”]=>
bool(false)
[“memCacheHost”]=>
NULL
[“memCachePort”]=>
int(11211)
[“memCacheCompress”]=>
bool(false)
[“sysUTimeStamp”]=>
bool(false)
[“arrayClass”]=>
string(18) “ADORecordSet_array”
[“noNullStrings”]=>
bool(false)
[“numQueries”]=>
int(8829359)
[“numCacheHits”]=>
int(0)
[“numCacheMisses”]=>
int(0)
[“pageExecuteCountRows”]=>
bool(true)
[“uniqueSort”]=>
bool(false)
[“leftOuter”]=>
bool(false)
[“rightOuter”]=>
bool(false)
[“poorAffectedRows”]=>
bool(false)
[“fnExecute”]=>
bool(false)
[“fnCacheExecute”]=>
bool(false)
[“rsPrefix”]=>
string(13) "ADORecordSet

[“autoCommit”]=>
bool(true)
[“transOff”]=>
int(0)
[“transCnt”]=>
int(0)
[“fetchMode”]=>
bool(false)
[“null2null”]=>
string(4) “null”
[“bulkBind”]=>
bool(false)
[“_oldRaiseFn”]=>
bool(false)
[“_transOK”]=>
NULL
[“_connectionID”]=>
resource(144) of type (pgsql link)
[“_errorMsg”]=>
string(0) “”
[“_errorCode”]=>
bool(false)
[“_queryID”]=>
resource(10257567) of type (Unknown)
[“_isPersistentConnection”]=>
bool(false)
[“_evalAll”]=>
bool(false)
[“_affected”]=>
bool(false)
[“_logsql”]=>
bool(false)
[“_transmode”]=>
string(0) “”
[“version”]=>
array(2) {
[“description”]=>
string(107) “PostgreSQL 9.4.7 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 5.3.1 20151207 (Red Hat 5.3.1-2), 64-bit”
[“version”]=>
string(5) “9.4.7”
}
[“pgVersion”]=>
float(9,4)
[“_nestedSQL”]=>
bool(true)
[“_metars”]=>
object(ADORecordSet_postgres7)#503 (30) {
[“databaseType”]=>
string(9) “postgres7”
[“_blobArr”]=>
NULL
[“canSeek”]=>
bool(true)
[“dataProvider”]=>
string(6) “native”
[“fields”]=>
bool(false)
[“blobSize”]=>
int(100)
[“sql”]=>
NULL
[“EOF”]=>
bool(false)
[“emptyTimeStamp”]=>
string(6) " "
[“emptyDate”]=>
string(6) " "
[“debug”]=>
bool(false)
[“timeCreated”]=>
int(0)
[“bind”]=>
bool(false)
[“fetchMode”]=>
int(3)
[“connection”]=>
RECURSION
[“_numOfRows”]=>
int(-1)
[“_numOfFields”]=>
int(-1)
[“_queryID”]=>
bool(false)
[“_currentRow”]=>
int(-1)
[“_closed”]=>
bool(false)
[“_inited”]=>
bool(false)
[“_obj”]=>
NULL
[“_names”]=>
NULL
[“_currentPage”]=>
int(-1)
[“_atFirstPage”]=>
bool(false)
[“_atLastPage”]=>
bool(false)
[“_lastPageNo”]=>
int(-1)
[“_maxRecordCount”]=>
int(0)
[“datetime”]=>
bool(false)
[“adodbFetchMode”]=>
int(0)
}
}
}
[“functionName”]=>
string(26) “_returnUserFromRowWithData”
[“idFields”]=>
array(0) {
}
[“records”]=>
NULL
[“wasEmpty”]=>
bool(true)
[“isFirst”]=>
bool(true)
[“isLast”]=>
bool(true)
[“page”]=>
int(1)
[“count”]=>
int(0)
[“pageCount”]=>
int(1)
}
PHP Fatal error: Call to a member function getId() on null in /var/www/html/ojs3/classes/install/Upgrade.inc.php on line 1025

I can send you a database dump and the full debug log if you wish.
I searched the code but can not find any place where the productionEditor migration is done.

Regards,
Tarcisio Pereira

Hmmm… @Tarcisio_Pereira, I think that our logic is not quite right in the upgrade script, but I will have to ask @asmecher: It seems that getDefaultByRoleId($journal->getId(), ROLE_ID_MANAGER) returns different groupId here https://github.com/pkp/ojs/blob/master/classes/install/Upgrade.inc.php#L253 and here https://github.com/pkp/ojs/blob/master/classes/install/Upgrade.inc.php#L1018. Because in this case the second time the groupId = 157 (production editor) is returned and we would actually like to get the ‘real’ journal manager :stuck_out_tongue: Thus, maybe we have to have something like “ORDER BY user_group_id” here https://github.com/pkp/pkp-lib/blob/master/classes/security/UserGroupDAO.inc.php#L249? Maybe also MySQL and PostgreSQL handle it differently in this case? Is there a more precise way to get the journal manager? I.e. I think we should get all userGroups with role_id = ROLE_ID_MANAGER (and not only one) and then go through till a user has been found? Would you agree @asmecher? Or, assign all userGroups with the role_id = ROLE_ID_MANAGER (journal manager, editor, production editor) to the old journal managers here: https://github.com/pkp/ojs/blob/master/classes/install/Upgrade.inc.php#L253-L254?

1 Like

Hi @bozana,

Ah, good spotting. In the case of the supplementary file migration, any user will do, so I’d suggest going through the user groups until a user is found. (This is already totally arbitrary, so no sense in getting fancy about how we find someone.)

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher and @bozana

So… Must I wait for a patch or can do I something to help?

Regards,
Tarcisio Pereira.

@Tarcisio_Pereira

Could you maybe try to order by user_group_id in the function UserGropuDAO::getByRoleId, so the function would look like:
> $params = array((int) $contextId, (int) $roleId);

  if ($default) $params[] = 1; // true
  $result = $this->retrieveRange(
  	'SELECT	*
  	FROM	user_groups
  	WHERE	context_id = ? AND
  		role_id = ?
  		' . ($default?' AND is_default = ?':'')
  		.' ORDER BY user_group_id',
  	$params,
  	$dbResultRange
  );  

Maybe this will already solve your problem. In the mean time I would add a new loop that would go through all groups found and let you know…

Thanks!
Bozana

1 Like

Hi @bozana and @asmecher

I did it, and:

Successfully upgraded to version 3.0.2.0

I will wait for the final solution before upgrade my ‘real instalation’:

Thank you both!

Regards,
Tarcisio Pereira.

Hi @Tarcisio_Pereira

I have the same problem, what have you changed to resolve the problem? Did you apply changes suggested by @bozana :[quote=“bozana, post:53, topic:25950”]
if ($default) $params = 1; // true
$result = $this->retrieveRange(
‘SELECT *
FROM user_groups
WHERE context_id = ? AND
role_id = ?
’ . ($default?’ AND is_default = ?‘:’‘)
.’ ORDER BY user_group_id’,
$params,
$dbResultRange
);
[/quote]

@Tarcisio_Pereira, great!
@atarix, what exactly errors do you get?

That error.

I have already checked that every journal has more than one Journal Manager and deleted all article_supplementary_files with no real article_files, but still get the error.

@atarix

Do you also use PostgreSQL? Could you try with the change above – to add " order by user_group_id" to function UserGropuDAO::getByRoleId?

Thanks!
Bozana

1 Like

Yes I use postgres and I can try your changes.
I’ll post the result as soon as possible.

Thanks
Giuseppe

1 Like

Hi @atarix

I have made this:
ojs3/lib/pkp/classes/security/UserGroupDAO.inc.php

241 function getByRoleId($contextId, $roleId, $default = false, $dbResultRange = null) {
242 $params = array((int) $contextId, (int) $roleId);
243 if ($default) $params = 1; // true
244 $result = $this->retrieveRange(
245 ‘SELECT *
246 FROM user_groups
247 WHERE context_id = ? AND
248 role_id = ?
249 ’ . ($default?’ AND is_default = ?‘:’')
250 .’ ORDER BY user_group_id’,
251 $params,
252 $dbResultRange
253 );
254
255 return new DAOResultFactory($result, $this, ‘_returnFromRow’);
256 }

Regards,
Tarcisio Pereira.