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.
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.