Error when saving new comment in front-end

12 views
Skip to first unread message

Kais msalmi

unread,
Jan 26, 2018, 8:33:55 AM1/26/18
to sonata-devs

Environment

Sonata packages

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle              3.31.0 = 3.31.0 The missing Symfony Admin Generator
sonata-project/block-bundle              3.11.0 = 3.11.0 Symfony SonataBlockBundle
sonata-project/cache                     2.0.1  = 2.0.1  Cache library
sonata-project/classification-bundle     3.6.0  = 3.6.0  Symfony SonataClassificationBundle
sonata-project/core-bundle               3.9.0  = 3.9.0  Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.3.1  = 2.3.1  Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.0.2  = 1.0.2  Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.4.1  = 3.4.1  Symfony Sonata / Integrate Doctrine ORM into the SonataAdm...
sonata-project/easy-extends-bundle       2.4.0  = 2.4.0  Symfony SonataEasyExtendsBundle
sonata-project/exporter                  1.8.0  = 1.8.0  Lightweight Exporter library
sonata-project/formatter-bundle          3.4.0  = 3.4.0  Symfony SonataFormatterBundle
sonata-project/intl-bundle               2.4.0  = 2.4.0  Symfony SonataIntlBundle
sonata-project/media-bundle              3.10.0 = 3.10.0 Symfony SonataMediaBundle
sonata-project/news-bundle               3.2.2  = 3.2.2  Symfony SonataNewsBundle
sonata-project/notification-bundle       3.3.0  = 3.3.0  Symfony SonataNotificationBundle
sonata-project/seo-bundle                2.5.0  = 2.5.0  Symfony SonataSeoBundle
sonata-project/timeline-bundle           3.1.1  ! 3.2.0  Integrates SpyTimelineBundle into Sonata
sonata-project/user-bundle               4.1.0  = 4.1.0  Symfony SonataUserBundle

Symfony packages

$ composer show --latest 'symfony/*'
symfony/monolog-bundle     v3.1.2  = v3.1.2 Symfony MonologBundle
symfony/phpunit-bridge     v3.4.3  ~ v4.0.3 Symfony PHPUnit Bridge
symfony/polyfill-apcu      v1.6.0  = v1.6.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-icu  v1.6.0  = v1.6.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring  v1.6.0  = v1.6.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php56     v1.6.0  = v1.6.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70     v1.6.0  = v1.6.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util      v1.6.0  = v1.6.0 Symfony utilities for portability of PHP codes
symfony/security-acl       v3.0.1  = v3.0.1 Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle v2.6.7  ~ v3.1.6 Symfony SwiftmailerBundle
symfony/symfony            v3.3.15 ~ v4.0.3 The Symfony PHP framework

PHP version

$ php -v
PHP 7.1.3 (cli) (built: Mar 14 2017 23:46:26) ( ZTS MSVC14 (Visual C++ 2015) x86 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.7, Copyright (c) 1999-2017, by Zend Technologies

sonata_news.yml

sonata_news:
    title:        Floussek Project
    link:         http://blog.floussek.com
    description:  Blog Floussek
    salt:         'secureToken'
    permalink_generator: sonata.news.permalink.date # sonata.news.permalink.collection
    permalink:
        date:     '%%1$04d/%%2$02d/%%3$02d/%%4$s' # => 2012/02/01/slug
    comment:
        notification:
            emails:   [msa...@gmail.com, msa...@yahoo.fr]
            from:     no-r...@Floussek-project.com
            template: 'SonataNewsBundle:Mail:comment_notification.txt.twig'

    class:
        post:       Application\Sonata\NewsBundle\Entity\Post
        comment:    Application\Sonata\NewsBundle\Entity\Comment
        tag:        Application\Sonata\ClassificationBundle\Entity\Tag
        collection: Application\Sonata\ClassificationBundle\Entity\Collection
        user:       Application\Sonata\UserBundle\Entity\User
        media:      Application\Sonata\MediaBundle\Entity\Media

    admin:
        post:
            class:       Sonata\NewsBundle\Admin\PostAdmin
            controller:  SonataAdminBundle:CRUD
            translation: SonataNewsBundle
        comment:
            class:       Sonata\NewsBundle\Admin\CommentAdmin
            controller:  SonataNewsBundle:CommentAdmin
            translation: SonataNewsBundle
doctrine:
    orm:
        entity_managers:
            default:
                mappings:
                    SonataNewsBundle: ~

Subject

error when saving new comment in front-end Post

Steps to reproduce

in the backend '/admin/sonata/news/comment/' adding comments is successfully
but in the frontend it returns this error:

Expected results

Cannot use object of type Symfony\Component\HttpFoundation\Request as array

in vendor\symfony\symfony\src\Symfony\Component\Form\Extension\Csrf\EventListener\CsrfValidationListener.php (line 62)

if (!isset($data[$this->fieldName]) || !$this->tokenManager->isTokenValid(new CsrfToken($this->tokenId, $data[$this->fieldName]))) {
Reply all
Reply to author
Forward
0 new messages