pkp / pkp-lib

The library used by PKP's applications OJS, OMP and OPS, open source software for scholarly publishing.
https://pkp.sfu.ca
GNU General Public License v3.0
304 stars 444 forks source link

InvalidArgumentException with locale key during upgrade #8823

Closed NateWr closed 1 year ago

NateWr commented 1 year ago

Describe the bug When upgrading from stable-3_3_0 to main, I get an InvalidArgumentException because the migration finds data with the en_US locale key and tries to set that as the current locale.

This exception does not seem to cause the upgrade to fail.

To Reproduce Steps to reproduce the behavior:

  1. Load the the stable-3_3_0/psql database dataset into a database.
  2. Update config.inc.php of a main branch checkout to that database.
  3. Run php tools/upgrade.php upgrade
  4. See errors

What application are you using? main branch (3.4 pre-release), PHP 8.1.16, Postgres 14.7

Additional information This effects several migrations. Exception 1:

2023-03-16 08:48:49 [migration: APP\migration\upgrade\v3_4_0\I7191_InstallSubmissionHelpDefaults]
InvalidArgumentException: Invalid/unsupported locale "en_US", default locale restored in lib/pkp/classes/i18n/Locale.php:140
Stack trace:
#0 lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(337): PKP\i18n\Locale->setLocale()
#1 lib/pkp/classes/migration/upgrade/v3_4_0/I7191_InstallSubmissionHelpDefaults.php(50): Illuminate\Support\Facades\Facade::__callStatic()
#2 lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(264): PKP\migration\upgrade\v3_4_0\I7191_InstallSubmissionHelpDefaults->PKP\migration\upgrade\v3_4_0\{closure}()
#3 lib/pkp/classes/migration/upgrade/v3_4_0/I7191_InstallSubmissionHelpDefaults.php(66): Illuminate\Support\Collection->each()
#4 lib/pkp/classes/install/Installer.php(461): PKP\migration\upgrade\v3_4_0\I7191_InstallSubmissionHelpDefaults->up()
#5 lib/pkp/classes/install/Installer.php(290): PKP\install\Installer->executeAction()
#6 lib/pkp/classes/install/Installer.php(205): PKP\install\Installer->executeInstaller()
#7 lib/pkp/classes/cliTool/UpgradeTool.php(95): PKP\install\Installer->execute()
#8 lib/pkp/classes/cliTool/UpgradeTool.php(68): PKP\cliTool\UpgradeTool->upgrade()
#9 tools/upgrade.php(21): PKP\cliTool\UpgradeTool->execute()
#10 {main}

Exception 2:

2023-03-16 08:48:49 [migration: APP\migration\upgrade\v3_4_0\I7191_SubmissionChecklistMigration]
InvalidArgumentException: Invalid/unsupported locale "en_US", default locale restored in lib/pkp/classes/i18n/Locale.php:140
Stack trace:
#0 lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(337): PKP\i18n\Locale->setLocale()
#1 lib/pkp/classes/migration/upgrade/v3_4_0/I7191_SubmissionChecklistMigration.php(68): Illuminate\Support\Facades\Facade::__callStatic()
#2 lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(264): PKP\migration\upgrade\v3_4_0\I7191_SubmissionChecklistMigration->PKP\migration\upgrade\v3_4_0\{closure}()
#3 lib/pkp/classes/migration/upgrade/v3_4_0/I7191_SubmissionChecklistMigration.php(84): Illuminate\Support\Collection->each()
#4 lib/pkp/classes/install/Installer.php(461): PKP\migration\upgrade\v3_4_0\I7191_SubmissionChecklistMigration->up()
#5 lib/pkp/classes/install/Installer.php(290): PKP\install\Installer->executeAction()
#6 lib/pkp/classes/install/Installer.php(205): PKP\install\Installer->executeInstaller()
#7 lib/pkp/classes/cliTool/UpgradeTool.php(95): PKP\install\Installer->execute()
#8 lib/pkp/classes/cliTool/UpgradeTool.php(68): PKP\cliTool\UpgradeTool->upgrade()
#9 tools/upgrade.php(21): PKP\cliTool\UpgradeTool->execute()
#10 {main}

Exception 3:

2023-03-16 08:48:49 [migration: APP\migration\upgrade\v3_4_0\I5716_EmailTemplateAssignments]
InvalidArgumentException: Invalid/unsupported locale "en_US", default locale restored in lib/pkp/classes/i18n/Locale.php:140
Stack trace:
#0 lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(337): PKP\i18n\Locale->setLocale()
#1 lib/pkp/classes/migration/upgrade/v3_4_0/I5716_EmailTemplateAssignments.php(237): Illuminate\Support\Facades\Facade::__callStatic()
#2 lib/pkp/classes/migration/upgrade/v3_4_0/I5716_EmailTemplateAssignments.php(54): PKP\migration\upgrade\v3_4_0\I5716_EmailTemplateAssignments->addDefaultTemplateNames()
#3 lib/pkp/classes/install/Installer.php(461): PKP\migration\upgrade\v3_4_0\I5716_EmailTemplateAssignments->up()
#4 lib/pkp/classes/install/Installer.php(290): PKP\install\Installer->executeAction()
#5 lib/pkp/classes/install/Installer.php(205): PKP\install\Installer->executeInstaller()
#6 lib/pkp/classes/cliTool/UpgradeTool.php(95): PKP\install\Installer->execute()
#7 lib/pkp/classes/cliTool/UpgradeTool.php(68): PKP\cliTool\UpgradeTool->upgrade()
#8 tools/upgrade.php(21): PKP\cliTool\UpgradeTool->execute()
#9 {main}
touhidurabir commented 1 year ago

probably a duplication of https://github.com/pkp/pkp-lib/issues/8766

jonasraoni commented 1 year ago

Yep, looks like the same.

And the exception is just an error_log(new Exception('...')) that I've added to capture the "context" before switching to the default locale.