fixAuthorGroup function in the update

Hi @asmecher

I am looking at the upgrade function here:

The sql there does not make sense to me. Should there be a WHERE clause there? I think it is now looping through the result and each time updating the user_group_id column for the whole authors table?

Hi @ajnyga,

Hmm, absolutely right. I’ve filed this at Author `user_group_id` upgrade `UPDATE` is broken · Issue #3289 · pkp/pkp-lib · GitHub. But I suspect that this column is dead weight – I’ve suggested an audit and possible removal in the filed issue.

Regards,
Alec Smecher
Public Knowledge Project Team

Thanks @asmecher

To be on the safe side, I changed that line to:
if ($authorGroup) $userGroupDao->update('UPDATE authors SET user_group_id = ? WHERE author_id = ?', array((int) $authorGroup->getId(), $row['author_id']));

That is probably how it was intended. The result was that the function finishes almost instantly whereas the old query took for hours.

Hi @ajnyga,

Thanks – your proposed fix is correct. I’ve committed it at the github entry above (both ojs-stable-3_1_0 and master). Glad to hear it also improves performance.

Regards,
Alec Smecher
Public Knowledge Project Team

Thanks @asmecher, I added one more comment to the issue, because I think that potentially journals upgrading with the version available at the PKP website will loose some metadata which can not be fixed later. I could be wrong.