Upgrade failed OJS3.1 to OJS3.3

When running the upgrade script it fails with this error

PHP Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘285-it_IT-preferredPublicName’ for key ‘author_settings_pkey’

The author_settings table seems to be updated quite a lot by this script.

table before:
before

table after:
after

This is the table schema:
table settings

As I can’t proceed with the upgrade I’m a bit stuck.

Because these elements ‘285-it_IT-preferredPublicName’ don’t exist before the upgrade script runs, I can’t see how to manuall fix this in MySQL?

Is it because the user has muliple languages set?

hi there,

Can you paste the author_settings entries from author 285 please?

Jason

here you go - this is before the upgrade:

"author_id","locale","setting_name","setting_value","setting_type"
285,"","orcid","","string"
285,"de_DE","affiliation","","string"
285,"de_DE","biography","","string"
285,"en_US","affiliation","University of KwaZulu-Natal","string"
285,"en_US","biography","<p>Professor, School of Education,&nbsp;University of KwaZulu-Natal</p>","string"
285,"it_IT","affiliation","","string"
285,"it_IT","biography","","string"

Here’s a screenshot
Screenshot_9

Hi @2020media

Sorry for the late reply, things are busy around PKPPS these days.

So, preferredPublicName is created in Upgrade.inc.php as part of the first bit of migration away from OJS 3.1. For each author it finds, it builds an author setting for preferredPublicName for each supported locale in the journal. The code that does this is:

foreach ($supportedLocales as $locale) {
     $preferredPublicName = "$firstName " . ($middleName != '' ? "$middleName " : '') . $lastName . ($suffix != '' ? ", $suffix" : '');
     if (AppLocale::isLocaleWithFamilyFirst($locale)) {
          $preferredPublicName = "$lastName, " . $firstName . ($middleName != '' ? " $middleName" : '');
     }
     $userDao->update(
          "INSERT INTO author_settings (author_id, locale, setting_name, setting_value, setting_type) VALUES (?, ?, 'preferredPublicName', ?, 'string')",
          [(int) $authorId, $locale, $preferredPublicName]
     );
 }

Is it possible that the it_IT locale is duplicated?

Cheers,
Jason