OJS [] Db insert error on "Create New Galley"

Hi all,
I upgraded to the latest version of 3.2.1.x ( to fix the problem that the search function did not work.
According to suggestion in post:

Now we have discovered another problem:
We can not create new Galleys.
When we click “Save” in the “Create New Galley” window nothing happens.

The error I find related to this in the server logs are:
First a warning:

PHP Warning:  in_array() expects parameter 2 to be array, null given in /var/www/html/ojs/lib/pkp/pages/workflow/PKPWorkflowHandler.inc.php on line 373, referer: https://journal.interbull.org/index.php/ib/workflow/index/1495/4

and then the error:

PHP Fatal error:  Uncaught Exception: DB Error: ERROR:  duplicate key value violates unique constraint "publication_galleys_pkey"\nDETAIL:  Key (galley_id)=(9) already exists. Query: INSERT INTO publication_galleys (locale, label, publication_id, url_path, remote_url) VALUES (?, ?, ?, ?, ?) in /var/www/html/ojs/lib/pkp/classes/db/DAO.inc.php:703\nStack trace:\n#0 /var/www/html/ojs/lib/pkp/classes/db/DAO.inc.php(231): DAO->handleError(Object(ADODB_postgres8), 'INSERT INTO pub...')\n#1 /var/www/html/ojs/lib/pkp/classes/db/SchemaDAO.inc.php(79): DAO->update('INSERT INTO pub...', Array)\n#2 /var/www/html/ojs/controllers/grid/articleGalleys/form/ArticleGalleyForm.inc.php(165): SchemaDAO->insertObject(Object(ArticleGalley))\n#3 /var/www/html/ojs/controllers/grid/articleGalleys/ArticleGalleyGridHandler.inc.php(405): ArticleGalleyForm->execute()\n#4 /var/www/html/ojs/lib/pkp/classes/core/PKPRouter.inc.php(391): ArticleGalleyGridHandler->updateGalley(Array, Object(Request))\n#5 /var/www/html/ojs/lib/pkp/classes/core/PKPComponentRouter.inc.php( in /var/www/html/ojs/lib/pkp/classes/db/DAO.inc.php on line 703, referer: https://journal.interbull.org/index.php/ib/workflow/index/1495/5

It looks like it want to insert a new row in the publication_galleys table with a galley_id that is already existing and galley_id is the primary key.

How can I solve this problem?

Many thanks in advance!!
Best regards

Hi all,
I finally find the problem.
For some reason had the sequence key been reset in the database:


To be able to fix this we took the largest galley_id in table increased it with one and set that to the next value for the sequence:

SELECT setval('publication_galleys_galley_id_seq', (SELECT max(galley_id)+1 FROM publication_galleys));

After this we were able to insert new galleys again!

Best regards

1 Like