Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding two collection items, only saves one, causes SQL error when deleting #1514

Closed
milosa opened this issue Jun 19, 2020 · 2 comments · Fixed by #1520
Closed

Adding two collection items, only saves one, causes SQL error when deleting #1514

milosa opened this issue Jun 19, 2020 · 2 comments · Fixed by #1520
Assignees

Comments

@milosa
Copy link

milosa commented Jun 19, 2020

Contenttype:

        site_images:
            label: Site foto's
            type: collection
            fields:
                header_image:
                    label: Site foto
                    type: set
                    fields:
                        image:
                            type: image
                            alt: true
                            upload: images

Details

Question Answer
Relevant Bolt Version 4 RC25
Install type Composer install
PHP version 7.4.7
Web server symfony
Database sqllite

Reproduction

Start with empty content type.

Then add one image to the collection. But don't save the contenttype content.
Add another item (with image) to the collection.

Now click save.

Problem 1: Only the first image is displayed in the collection. The second collection item is displayed, but it is empty. (No image)

Problem 2: Hit remove item on the empty collection item, then clicking save, causes this SQL error:

php.CRITICAL: Error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: bolt_field.content_id in (...)/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:127 Stack trace: 
#0 (...)/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php(127): PDOStatement->execute(NULL) 
#1 (...)/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php(153): Doctrine\DBAL\Driver\PDOStatement->execute(NULL) 
#2 (...)/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php(286): Doctrine\DBAL\Statement->execute() 
#3 (...)/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(1087): Doctrine\ORM\Persisters\Entity\BasicEntityPersister->executeInserts() 
#4 (...)/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php( {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: bolt_field.content_id in (...)/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:127\nStack trace:\n
#0 (...)/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php(127): PDOStatement->execute(NULL)\n
#1 (...)/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php(153): Doctrine\\DBAL\\Driver\\PDOStatement->execute(NULL)\n
#2 (...)/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php(286): Doctrine\\DBAL\\Statement->execute()\n
#3 (...)/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(1087): Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister->executeInserts()\n
#4 (...)/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php( at (...)/vendor/symfony/http-kernel/Controller/ControllerResolver.php:88)"} []

@milosa
Copy link
Author

milosa commented Jun 19, 2020

I'm getting some other weird behavior as well.
I forgot to enter the alt field of the second image. So I did this. Saved the content type.

Then I got a similar error

[2020-06-19 10:32:07] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\NotNullConstraintViolationException: "An exception occurred while executing 'INSERT INTO bolt_field (name, sortorder, version, content_id, parent_id, type) VALUES (?, ?, ?, ?, ?, ?)'

But now both my collection items are empty (not showing an image in the backend).

Edit: It's now to the point that I can't use the collection anymore. Editing an item (the alt attribute) causes it to remove the images from all other items in the collection. (or at least it stops showing them)

When I add a new item, it stops showing the images in the existing items.

@I-Valchev
Copy link
Member

Nice spot, interesting that it only happens in such specific cases. A fix is in the pipeline :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants