Cannot remove journal in OJS 3.4.0.8 multijournal installation

I am OJS manager and responsible for everything that can be done on the user interface (not the server), journal management, user management, website style, …
When trying to remove an old journal we used for testing and reviewing galley files in our multijournal installation, it did not work. In administration → site management → hosted journals I removed all users but one (the admin account) from the journal in question and then clicked on “remove” to delete the journal and all its content. The window for confirmation opened and I clicked ‘ok’ but nothing happened. The error log shows:

[Mon Feb 17 09:34:19.469631 2025] [proxy_fcgi:error] [pid 1317441:tid 139749851027008] [remote IP redacted] AH01071: Got error ‘PHP message: PHP Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (ojs.authors, CONSTRAINT authors_user_group_id_foreign FOREIGN KEY (user_group_id) REFERENCES user_groups (user_group_id)) in /var/www/redacted/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php:570\nStack trace:\n#0 /var/www/redacted/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(570): PDOStatement->execute()\n#1 /var/www/redacted/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(753): Illuminate\Database\Connection->Illuminate\Database\{closure}()\n#2 /var/www/redacted/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(720): Illuminate\Database\Connection->runQueryCallback()\n#3 /var/www/redacted/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(5…’, referer: https://redacted/index.php/index/admin/contexts

What can I do to fix this?

We use OJS 3.4.0.8 that was recently upgraded from OJS 3.3.0.8 (started out as 2.2.3.0 in 2009 and went through several upgrades since)
multijournal installation (7 active journals + 3 hidden journals for internal use only)
PHP version 8.3.16

I am also experiencing the same issue. Looking for solution.
I have tested with my OJS 3.3.0.20 and able to remove the journal but after upgrading the same to 3.4.0.8, I am not able to delete the journal and error log shows exactly the same as described above.

Hi @seisense,

See:

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Dear all,

upgrading to 3.4 did not solve the problem. We encountered the problem after upgrading to 3.4.0.8. The suggestion is now to wait for 3.5?

Hi @heike_riegler,

The problem you’re encountering is a little different… At a glance, you should be able to resolve it by applying this patch:

diff --git a/lib/pkp/classes/services/PKPContextService.php b/lib/pkp/classes/services/PKPContextService.php
index 5a6a549a80..5923731d7f 100644
--- a/lib/pkp/classes/services/PKPContextService.php
+++ b/lib/pkp/classes/services/PKPContextService.php
@@ -601,8 +601,6 @@ abstract class PKPContextService implements EntityPropertyInterface, EntityReadI
         $announcementTypeDao = DAORegistry::getDAO('AnnouncementTypeDAO'); /** @var AnnouncementTypeDAO $announcementTypeDao */
         $announcementTypeDao->deleteByContextId($context->getId());
 
-        Repo::userGroup()->deleteByContextId($context->getId());
-
         $genreDao = DAORegistry::getDAO('GenreDAO'); /** @var GenreDAO $genreDao */
         $genreDao->deleteByContextId($context->getId());
 
diff --git a/classes/services/ContextService.php b/classes/services/ContextService.php
index 59457f4581..555fbea8e5 100644
--- a/classes/services/ContextService.php
+++ b/classes/services/ContextService.php
@@ -185,6 +185,8 @@ class ContextService extends \PKP\services\PKPContextService
 
         Repo::submission()->deleteByContextId($context->getId());
 
+        Repo::userGroup()->deleteByContextId($context->getId());
+
         $publicFileManager = new PublicFileManager();
         $publicFileManager->rmtree($publicFileManager->getContextFilesPath($context->getId()));
     }

Could you try it and let me know?

Thanks,
Alec Smecher
Public Knowledge Project Team

@asmecher Same context and same problem here, trying to delete a journal on an install that was upgraded from 3.3.0-20 to 3.4.0-8:

PHP Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails ('ojs_test'.'dois', CONSTRAINT 'dois_context_id_foreign' FOREIGN KEY ('context_id') REFERENCES 'journals' ('journal_id'))

I modified the files as suggested:

lib/pkp/classes/services/PKPContextService.php

classes/services/ContextService.php

I still get the same error.

Hi @nicolasd,

That’s a different but similar error. Could you try the following additional patch?

diff --git a/lib/pkp/classes/migration/upgrade/v3_4_0/PKPI7014_DoiMigration.php b/lib/pkp/classes/migration/upgrade/v3_4_0/PKPI7014_DoiMigration.php
index 2215a1727a..58cec9dfb5 100644
--- a/lib/pkp/classes/migration/upgrade/v3_4_0/PKPI7014_DoiMigration.php
+++ b/lib/pkp/classes/migration/upgrade/v3_4_0/PKPI7014_DoiMigration.php
@@ -33,7 +33,7 @@ abstract class PKPI7014_DoiMigration extends Migration
             $table->bigInteger('doi_id')->autoIncrement();
 
             $table->bigInteger('context_id');
-            $table->foreign('context_id')->references($this->getContextIdColumn())->on($this->getContextTable());
+            $table->foreign('context_id')->references($this->getContextIdColumn())->on($this->getContextTable())->onDelete('cascade');
             $table->index(['context_id'], 'dois_context_id');
 
             $table->string('doi');

Thanks,
Alec Smecher
Public Knowledge Project Team

Additional patch applied on lib/pkp/classes/migration/upgrade/v3_4_0/PKPI7014_DoiMigration.php

… but still the same error. :face_with_diagonal_mouth:

PHP Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails ('ojs_test'.'dois', CONSTRAINT 'dois_context_id_foreign' FOREIGN KEY ('context_id') REFERENCES 'journals' ('journal_id'))

I’ve resolved this with SQL:

MariaDB [ojs]> DELETE FROM journals WHERE journal_id=XX;

MariaDB [ojs]> ALTER TABLE dois
→ DROP FOREIGN KEY dois_context_id_foreign;

MariaDB [ojs]> ALTER TABLE dois
→ ADD CONSTRAINT dois_context_id_foreign
→ FOREIGN KEY (context_id)
→ REFERENCES journals (journal_id)
→ ON DELETE CASCADE;

MariaDB [ojs]> DELETE FROM journals WHERE journal_id=XX;

MariaDB [ojs]> ALTER TABLE review_assignments
→ DROP FOREIGN KEY review_assignments_submission_id_foreign;

MariaDB [ojs]> ALTER TABLE review_assignments
→ ADD CONSTRAINT review_assignments_submission_id_foreign
→ FOREIGN KEY (submission_id)
→ REFERENCES submissions (submission_id)
→ ON DELETE CASCADE;

MariaDB [ojs]> DELETE FROM journals WHERE journal_id=XX;

Today after upgrading from OJS 3.3.0-8 to 3.4.0-10 We ran into the same issue - can not delete journal. I am wondering if anyone has a solution for this.

[11-Feb-2026 11:25:46 America/Edmonton] PHP Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`ojs2`.`authors`, CONSTRAINT `authors_user_group_id_foreign` FOREIGN KEY (`user_group_id`) REFERENCES `user_groups` (`user_group_id`)) in /var/www/html/ojs-3.4.0-10/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php:570
Stack trace:
#0 /var/www/html/ojs-3.4.0-10/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(570): PDOStatement->execute()
#1 /var/www/html/ojs-3.4.0-10/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/ojs-3.4.0-10/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/ojs-3.4.0-10/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(558): Illuminate\Database\Connection->run(‘delete from `us…’, Array, Object(Closure))
#4 /var/www/html/ojs-3.4.0-10/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(522): Illuminate\Database\Connection->affectingStatement(‘delete from `us…’, Array)
#5 /var/www/html/ojs-3.4.0-10/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(3550): Illuminate\Database\Connection->delete(‘delete from `us…’, Array)
#6 /var/www/html/ojs-3.4.0-10/lib/pkp/classes/core/EntityDAO.php(270): Illuminate\Database\Query\Builder->delete()
#7 /var/www/html/ojs-3.4.0-10/lib/pkp/classes/userGroup/Repository.php(180): PKP\core\EntityDAO->deleteById(31)
#8 /var/www/html/ojs-3.4.0-10/lib/pkp/classes/services/PKPContextService.php(604): PKP\userGroup\Repository->deleteByContextId(102)
#9 /var/www/html/ojs-3.4.0-10/lib/pkp/controllers/grid/admin/context/ContextGridHandler.php(289): PKP\services\PKPContextService->delete(Object(APP\journal\Journal))
#10 [internal function]: PKP\controllers\grid\admin\context\ContextGridHandler->deleteContext(Array, Object(APP\core\Request))
#11 /var/www/html/ojs-3.4.0-10/lib/pkp/classes/core/PKPRouter.php(334): call_user_func(Array, Array, Object(APP\core\Request))
#12 /var/www/html/ojs-3.4.0-10/lib/pkp/classes/core/PKPComponentRouter.php(291): PKP\core\PKPRouter->_authorizeInitializeAndCallRequest(Array, Object(APP\core\Request), Array)
#13 /var/www/html/ojs-3.4.0-10/lib/pkp/classes/core/Dispatcher.php(165): PKP\core\PKPComponentRouter->route(Object(APP\core\Request))
#14 /var/www/html/ojs-3.4.0-10/lib/pkp/classes/core/PKPApplication.php(395): PKP\core\Dispatcher->dispatch(Object(APP\core\Request))
#15 /var/www/html/ojs-3.4.0-10/index.php(21): PKP\core\PKPApplication->execute()
#16 {main}

I tried the above suggestion from @trace but right off the bat it is an error. I think deleting records from a backend relational database is a risky move unless one really knows the database schema, constrains, and their relationships.

ALTER TABLE dois DROP FOREIGN KEY dois_context_id_foreign;

I do not think I want to drop foreign key in dois_context_id_foreign table - they are there for a reason and so on.

Thank you in advance.

Best regards,

Dung.

Hi @dung, could you run the following query to help verify the issue and share the results?

SELECT
  CONSTRAINT_NAME,
  DELETE_RULE
FROM information_schema.REFERENTIAL_CONSTRAINTS
WHERE CONSTRAINT_SCHEMA = DATABASE()
  AND TABLE_NAME = 'authors'
  AND REFERENCED_TABLE_NAME = 'user_groups';


Thank you - Kaitlin.

D.

Hi @dung, thanks for verifying.

Here are a couple of queries you can try (run the first then the second), similar to the solution above but altered for your issue (make sure to take a backup before running these!):

ALTER TABLE authors
  DROP FOREIGN KEY authors_user_group_id_foreign;

ALTER TABLE authors
  ADD CONSTRAINT authors_user_group_id_foreign
  FOREIGN KEY (user_group_id)
  REFERENCES user_groups(user_group_id)
  ON DELETE CASCADE;

Then when those have run successfully, try deleting the journal again.

Hello @kaitlin

I backed up and tried it first in dev server and I got error:

[24-Feb-2026 14:41:22 America/Edmonton] PHP Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (ojs.dois, CONSTRAINT dois_context_id_foreign FOREIGN KEY (context_id) REFERENCES journals (journal_id)) in /serverojs-3.4.0-10/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php:570
Stack trace:
#0 /serverojs-3.4.0-10/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(570): PDOStatement->execute()
#1 /serverojs-3.4.0-10/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(753): Illuminate\Database\Connection->Illuminate\Database{closure}(‘DELETE FROM jou…’, Array)
#2 /serverojs-3.4.0-10/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(720): Illuminate\Database\Connection->runQueryCallback(‘DELETE FROM jou…’, Array, Object(Closure))
#3 /serverojs-3.4.0-10/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(558): Illuminate\Database\Connection->run(‘DELETE FROM jou…’, Array, Object(Closure))
#4 /serverojs-3.4.0-10/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(469): Illuminate\Database\Connection->affectingStatement(‘DELETE FROM jou…’, Array)
#5 /serverojs-3.4.0-10/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(338): Illuminate\Database\DatabaseManager->__call(‘affectingStatem…’, Array)
#6 /serverojs-3.4.0-10/lib/pkp/classes/db/DAO.php(179): Illuminate\Support\Facades\Facade::__callStatic(‘affectingStatem…’, Array)
#7 /serverojs-3.4.0-10/lib/pkp/classes/db/SchemaDAO.php(213): PKP\db\DAO->update(‘DELETE FROM jou…’, Array)
#8 /serverojs-3.4.0-10/lib/pkp/classes/db/SchemaDAO.php(203): PKP\db\SchemaDAO->deleteById(1)
#9 /serverojs-3.4.0-10/lib/pkp/classes/services/PKPContextService.php(649): PKP\db\SchemaDAO->deleteObject(Object(APP\journal\Journal))
#10 /serverojs-3.4.0-10/lib/pkp/controllers/grid/admin/context/ContextGridHandler.php(289): PKP\services\PKPContextService->delete(Object(APP\journal\Journal))
#11 [internal function]: PKP\controllers\grid\admin\context\ContextGridHandler->deleteContext(Array, Object(APP\core\Request))
#12 /serverojs-3.4.0-10/lib/pkp/classes/core/PKPRouter.php(334): call_user_func(Array, Array, Object(APP\core\Request))
#13 /serverojs-3.4.0-10/lib/pkp/classes/core/PKPComponentRouter.php(291): PKP\core\PKPRouter->_authorizeInitializeAndCallRequest(Array, Object(APP\core\Request), Array)
#14 /serverojs-3.4.0-10/lib/pkp/classes/core/Dispatcher.php(165): PKP\core\PKPComponentRouter->route(Object(APP\core\Request))
#15 /serverojs-3.4.0-10/lib/pkp/classes/core/PKPApplication.php(395): PKP\core\Dispatcher->dispatch(Object(APP\core\Request))
#16 /serverojs-3.4.0-10/index.php(21): PKP\core\PKPApplication->execute()
#17 {main}

Next Illuminate\Database\QueryException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (ojs.dois, CONSTRAINT dois_context_id_foreign FOREIGN KEY (context_id) REFERENCES journals (journal_id)) (SQL: DELETE FROM journals WHERE journal_id = 1) in /serverojs-3.4.0-10/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php:760
Stack trace:
#0 /serverojs-3.4.0-10/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(720): Illuminate\Database\Connection->runQueryCallback(‘DELETE FROM jou…’, Array, Object(Closure))
#1 /serverojs-3.4.0-10/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(558): Illuminate\Database\Connection->run(‘DELETE FROM jou…’, Array, Object(Closure))
#2 /serverojs-3.4.0-10/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(469): Illuminate\Database\Connection->affectingStatement(‘DELETE FROM jou…’, Array)
#3 /serverojs-3.4.0-10/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(338): Illuminate\Database\DatabaseManager->__call(‘affectingStatem…’, Array)
#4 /serverojs-3.4.0-10/lib/pkp/classes/db/DAO.php(179): Illuminate\Support\Facades\Facade::__callStatic(‘affectingStatem…’, Array)
#5 /serverojs-3.4.0-10/lib/pkp/classes/db/SchemaDAO.php(213): PKP\db\DAO->update(‘DELETE FROM jou…’, Array)
#6 /serverojs-3.4.0-10/lib/pkp/classes/db/SchemaDAO.php(203): PKP\db\SchemaDAO->deleteById(1)
#7 /serverojs-3.4.0-10/lib/pkp/classes/services/PKPContextService.php(649): PKP\db\SchemaDAO->deleteObject(Object(APP\journal\Journal))
#8 /serverojs-3.4.0-10/lib/pkp/controllers/grid/admin/context/ContextGridHandler.php(289): PKP\services\PKPContextService->delete(Object(APP\journal\Journal))
#9 [internal function]: PKP\controllers\grid\admin\context\ContextGridHandler->deleteContext(Array, Object(APP\core\Request))
#10 /serverojs-3.4.0-10/lib/pkp/classes/core/PKPRouter.php(334): call_user_func(Array, Array, Object(APP\core\Request))
#11 /serverojs-3.4.0-10/lib/pkp/classes/core/PKPComponentRouter.php(291): PKP\core\PKPRouter->_authorizeInitializeAndCallRequest(Array, Object(APP\core\Request), Array)
#12 /serverojs-3.4.0-10/lib/pkp/classes/core/Dispatcher.php(165): PKP\core\PKPComponentRouter->route(Object(APP\core\Request))
#13 /serverojs-3.4.0-10/lib/pkp/classes/core/PKPApplication.php(395): PKP\core\Dispatcher->dispatch(Object(APP\core\Request))
#14 /serverojs-3.4.0-10/index.php(21): PKP\core\PKPApplication->execute()
#15 {main}
thrown in /serverojs-3.4.0-10/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 760
^C
[server php-fpm]#

Also front end error:

Best regards,

D.

Hi @dung, it sounds like the first issue has been resolved and you’re now encountering the same issue on a different table, similar to above. Can you try these two queries now as well (making sure to back up first!):

ALTER TABLE dois
  DROP FOREIGN KEY dois_context_id_foreign;

ALTER TABLE dois
  ADD CONSTRAINT dois_context_id_foreign
  FOREIGN KEY (context_id)
  REFERENCES journals (journal_id)
  ON DELETE CASCADE;

… and see if you get any new errors now trying to delete the journal?

Great news @kaitlin

Hi I tried it on dev server and it works perfectly! Thank you so much for your help!

Best,

Dung.

1 Like

That’s great @dung! I’ve filed an issue in our GitHub for this so we can get this fixed for future upgrades:

1 Like