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
307 stars 448 forks source link

Fatal error on the RemoveUnvalidatedExpiredUsers task #10143

Open jonasraoni opened 5 months ago

jonasraoni commented 5 months ago

Describe the bug After running the RemoveUnvalidatedExpiredUsers I see the exception below.

One question: are we supposed to remove users which are assigned to something in the workflow? I think it might be ok, but raises questions like "I'm sure I've assigned you to this, but now I can't find the assignment anymore".

PHP Fatal error:  Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`ojsdb`.`review_assignments`, CONSTRAINT `review_assignments_reviewer_id_foreign` FOREIGN KEY (`reviewer_id`) REFERENCES `users` (`user_id`)) in /var/www/html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php:570
Stack trace:
#0 /var/www/html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(570): PDOStatement->execute()
#1 /var/www/html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(753): Illuminate\Database\Connection->Illuminate\Database\{closure}('delete from `us...', Array)
#2 /var/www/html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(720): Illuminate\Database\Connection->runQueryCallback('delete from `us...', Array, Object(Closure))
#3 /var/www/html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(577): Illuminate\Database\Connection->run('delete from `us...', Array, Object(Closure))
#4 /var/www/html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(522): Illuminate\Database\Connection->affectingStatement('delete from `us...', Array)
#5 /var/www/html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(3552): Illuminate\Database\Connection->delete('delete from `us...', Array)
#6 /var/www/html/lib/pkp/classes/core/EntityDAO.php(270): Illuminate\Database\Query\Builder->delete()
#7 /var/www/html/lib/pkp/classes/core/EntityDAO.php(260): PKP\core\EntityDAO->deleteById(7803)
#8 /var/www/html/lib/pkp/classes/user/DAO.php(278): PKP\core\EntityDAO->_delete(Object(PKP\user\User))
#9 /var/www/html/lib/pkp/classes/user/Repository.php(129): PKP\user\DAO->delete(Object(PKP\user\User))
#10 /var/www/html/lib/pkp/classes/user/DAO.php(349): PKP\user\Repository->delete(Object(PKP\user\User))
#11 /var/www/html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(235): PKP\user\DAO->PKP\user\{closure}(Object(stdClass), 71)
#12 /var/www/html/lib/pkp/classes/user/DAO.php(349): Illuminate\Support\Collection->each(Object(Closure))
#13 /var/www/html/lib/pkp/classes/user/Repository.php(423): PKP\user\DAO->deleteUnvalidatedExpiredUsers(Object(Carbon\Carbon), Array)
#14 /var/www/html/lib/pkp/classes/task/RemoveUnvalidatedExpiredUsers.php(53): PKP\user\Repository->deleteUnvalidatedExpiredUsers(Object(Carbon\Carbon))
#15 /var/www/html/lib/pkp/classes/scheduledTask/ScheduledTask.php(165): PKP\task\RemoveUnvalidatedExpiredUsers->executeActions()
#16 /var/www/html/lib/pkp/classes/cliTool/ScheduledTaskTool.php(134): PKP\scheduledTask\ScheduledTask->execute()
#17 /var/www/html/lib/pkp/classes/cliTool/ScheduledTaskTool.php(111): PKP\cliTool\ScheduledTaskTool->executeTask('PKP\\task\\Remove...', Array)
#18 /var/www/html/lib/pkp/classes/cliTool/ScheduledTaskTool.php(81): PKP\cliTool\ScheduledTaskTool->parseTasks('registry/schedu...')
#19 /var/www/html/tools/runScheduledTasks.php(24): PKP\cliTool\ScheduledTaskTool->execute()
#20 {main}

Next Illuminate\Database\QueryException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`ojsdb`.`review_assignments`, CONSTRAINT `review_assignments_reviewer_id_foreign` FOREIGN KEY (`reviewer_id`) REFERENCES `users` (`user_id`)) (SQL: delete from `users` where `user_id` = 7803) in /var/www/html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php:760
Stack trace:
#0 /var/www/html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(720): Illuminate\Database\Connection->runQueryCallback('delete from `us...', Array, Object(Closure))
#1 /var/www/html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(577): Illuminate\Database\Connection->run('delete from `us...', Array, Object(Closure))
#2 /var/www/html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(522): Illuminate\Database\Connection->affectingStatement('delete from `us...', Array)
#3 /var/www/html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(3552): Illuminate\Database\Connection->delete('delete from `us...', Array)
#4 /var/www/html/lib/pkp/classes/core/EntityDAO.php(270): Illuminate\Database\Query\Builder->delete()
#5 /var/www/html/lib/pkp/classes/core/EntityDAO.php(260): PKP\core\EntityDAO->deleteById(7803)
#6 /var/www/html/lib/pkp/classes/user/DAO.php(278): PKP\core\EntityDAO->_delete(Object(PKP\user\User))
#7 /var/www/html/lib/pkp/classes/user/Repository.php(129): PKP\user\DAO->delete(Object(PKP\user\User))
#8 /var/www/html/lib/pkp/classes/user/DAO.php(349): PKP\user\Repository->delete(Object(PKP\user\User))
#9 /var/www/html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(235): PKP\user\DAO->PKP\user\{closure}(Object(stdClass), 71)
#10 /var/www/html/lib/pkp/classes/user/DAO.php(349): Illuminate\Support\Collection->each(Object(Closure))
#11 /var/www/html/lib/pkp/classes/user/Repository.php(423): PKP\user\DAO->deleteUnvalidatedExpiredUsers(Object(Carbon\Carbon), Array)
#12 /var/www/html/lib/pkp/classes/task/RemoveUnvalidatedExpiredUsers.php(53): PKP\user\Repository->deleteUnvalidatedExpiredUsers(Object(Carbon\Carbon))
#13 /var/www/html/lib/pkp/classes/scheduledTask/ScheduledTask.php(165): PKP\task\RemoveUnvalidatedExpiredUsers->executeActions()
#14 /var/www/html/lib/pkp/classes/cliTool/ScheduledTaskTool.php(134): PKP\scheduledTask\ScheduledTask->execute()
#15 /var/www/html/lib/pkp/classes/cliTool/ScheduledTaskTool.php(111): PKP\cliTool\ScheduledTaskTool->executeTask('PKP\\task\\Remove...', Array)
#16 /var/www/html/lib/pkp/classes/cliTool/ScheduledTaskTool.php(81): PKP\cliTool\ScheduledTaskTool->parseTasks('registry/schedu...')
#17 /var/www/html/tools/runScheduledTasks.php(24): PKP\cliTool\ScheduledTaskTool->execute()
#18 {main}
  thrown in /var/www/html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 760

What application are you using? OJS 3.4

asmecher commented 5 months ago

Unvalidated users won't have any workflow participation, so it's OK to nuke them from space. Otherwise, that's why we have "merge users" (transferring all assets to another account) rather than a "delete" function, despite the confusion this often causes.