FriendsOfSymfony / FOSCommentBundle

Threaded comments for Symfony
http://friendsofsymfony.github.com/
MIT License
462 stars 230 forks source link

Commenting without a parent comment triggers error #664

Open jspeedz opened 6 years ago

jspeedz commented 6 years ago

Hello!

I have an issue where a MySQL query triggers an error. I was wondering if this is a known issue, or something specific to my environment.

It seems like doctrine converts an empty array to null instead of like an empty string like it did before (it has worked before). The getAncestors() method of the entity it is trying to save returns an empty array.

Package versions:

Edit: I just upgraded the package to 2.2.0 and applied the fix in #662 . I still have the same problem


An exception occurred while executing 'INSERT INTO comment (ancestors, updated_at, edited, thread_id, author_id) VALUES (?, ?, ?, ?, ?)' with params [null, "2018-09-05 16:24:11", 0, 924, 21]:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'ancestors' cannot be null

  at vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:122
  at Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException('An exception occurred while executing \'INSERT INTO comment (ancestors, updated_at, edited, thread_id, author_id) VALUES (?, ?, ?, ?, ?)\' with params [null, "2018-09-05 16:24:11", 0, 924, 21]:SQLSTATE[23000]: Integrity constraint violation: 1048 Column \'ancestors\' cannot be null', object(PDOException))
     (vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:184)
  at Doctrine\DBAL\DBALException::wrapException(object(Driver), object(PDOException), 'An exception occurred while executing \'INSERT INTO comment (ancestors, updated_at, edited, thread_id, author_id) VALUES (?, ?, ?, ?, ?)\' with params [null, "2018-09-05 16:24:11", 0, 924, 21]:SQLSTATE[23000]: Integrity constraint violation: 1048 Column \'ancestors\' cannot be null')
     (vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:158)
  at Doctrine\DBAL\DBALException::driverExceptionDuringQuery(object(Driver), object(PDOException), 'INSERT INTO comment (ancestors, updated_at, edited, thread_id, author_id) VALUES (?, ?, ?, ?, ?)', array(null, '2018-09-05 16:24:11', 0, 924, 21))
     (vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php:178)
  at Doctrine\DBAL\Statement->execute()
     (vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:285)
  at Doctrine\ORM\Persisters\Entity\BasicEntityPersister->executeInserts()
     (vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:1073)
  at Doctrine\ORM\UnitOfWork->executeInserts(object(ClassMetadata))
     (vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:386)
  at Doctrine\ORM\UnitOfWork->commit(null)
     (vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:358)
  at Doctrine\ORM\EntityManager->flush(null)
     (var/cache/dev/appDevDebugProjectContainer.php:11596)
  at DoctrineORMEntityManager_000000003e86af43000000004aafd962cdb39e43f97aef6f90a953c3441a8f88->flush()
     (vendor/friendsofsymfony/comment-bundle/FOS/CommentBundle/Entity/CommentManager.php:128)
  at FOS\CommentBundle\Entity\CommentManager->doSaveComment(object(Comment))
     (vendor/friendsofsymfony/comment-bundle/FOS/CommentBundle/Model/CommentManager.php:136)
  at FOS\CommentBundle\Model\CommentManager->saveComment(object(Comment))
     (vendor/friendsofsymfony/comment-bundle/FOS/CommentBundle/Acl/AclCommentManager.php:133)
  at FOS\CommentBundle\Acl\AclCommentManager->saveComment(object(Comment))
     (vendor/friendsofsymfony/comment-bundle/FOS/CommentBundle/Controller/ThreadController.php:495)
  at FOS\CommentBundle\Controller\ThreadController->postThreadCommentsAction(object(Request), '924')
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:151)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:68)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:169)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (web/app_dev.php:31)