sonata-project / SonataNewsBundle

[Abandoned] Symfony SonataNewsBundle
https://docs.sonata-project.org/projects/SonataNewsBundle
MIT License
151 stars 131 forks source link

"Notice: Undefined index: tags" at .../vendor/sonata-project/doctrine-orm-admin-bundle/Guesser/FilterTypeGuesser.php line 64 #236

Closed Polm1 closed 9 years ago

Polm1 commented 9 years ago

Hi I'm stuck with this error when I'm trying to acces to the post list section in sonata admin.

I've followed the official doc for master version of this bundle but first problems where when trying to extend Classification Bundle and News Bundle ([Doctrine\ODM\MongoDB\Mapping\MappingException] No identifier/primary key specified for Document 'Application\Sonata\Classi ficationBundle\Document\Tag'. Every Document must have an identifier/primar y key.)

So I've deleted from Application\ClassificationBundle\config\doctrine.mongodb.xml because I don't need them (I'm using Postgresql and nor in my config.yml I will this bundles mapped by mongo) and everything was seeming fine excepet that problem which I'm stuck in when trying to show post list.

I've tried all the others functionality of classification and news bundle (create tags, context, showing them, create a new media gallery with media bundle, comments list), so I think that everything else should be in order and I can't recognize where can be the error.

My composer.json:

"doctrine/doctrine-bundle": "~1.3@dev",
"sonata-project/core-bundle": "2.3.*@dev",
"sonata-project/admin-bundle": "2.4.*@dev",
"sonata-project/user-bundle": "2.3.*@dev",
"sonata-project/doctrine-mongodb-admin-bundle": "2.3.*@dev",
"sonata-project/easy-extends-bundle": "2.1.*@dev",
"sonata-project/block-bundle": "2.3.*@dev",
"sonata-project/doctrine-orm-admin-bundle": "2.4.*@dev",
"sonata-project/cache-bundle": "~2.2@dev",
"sonata-project/seo-bundle": "2.0.*@dev",
"sonata-project/notification-bundle": "~2.3@dev",
"symfony-cmf/routing-bundle": "~1.4@dev",
"sonata-project/page-bundle": "2.4.*@dev",
"sonata-project/datagrid-bundle": "2.2.*@dev",
"sonata-project/classification-bundle": "2.3.*@dev",
"sonata-project/intl-bundle": "2.2.*@dev",
"sonata-project/media-bundle": "2.4.*@dev",
"sonata-project/news-bundle": "2.4.*@dev",
"sonata-project/formatter-bundle": "2.4.*@dev"

And my confs files (imported in config.yml)

# sonata_classification.yml
sonata_classification:
    class:
        tag:          Application\Sonata\ClassificationBundle\Entity\Tag
        category:     Application\Sonata\ClassificationBundle\Entity\Category
        collection:   Application\Sonata\ClassificationBundle\Entity\Collection

    admin:
        tag:
            class:        Sonata\ClassificationBundle\Admin\TagAdmin
            controller:   SonataAdminBundle:CRUD
            translation:  SonataClassificationBundle
        category:
            class:        Sonata\ClassificationBundle\Admin\CategoryAdmin
            controller:   SonataAdminBundle:CRUD
            translation:  SonataClassificationBundle
        collection:
            class:        Sonata\ClassificationBundle\Admin\CollectionAdmin
            controller:   SonataAdminBundle:CRUD
            translation:  SonataClassificationBundle

doctrine:
    orm:
        entity_managers:
            default:
                auto_mapping: true
                #metadata_cache_driver: apc
                #query_cache_driver: apc
                #result_cache_driver: apc
                mappings:
                    ApplicationSonataClassificationBundle: ~
                    SonataClassificationBundle: ~

#sonata_news.yml
sonata_news:
    title:        Sonata Project
    link:         http://sonata-project.org
    description:  Cool bundles on top of Symfony2
    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:   [email@example.org, email2@example.org]
            from:     no-reply@sonata-project.org
            template: 'SonataNewsBundle:Mail:comment_notification.txt.twig'

    class:
        post:       Application\Sonata\NewsBundle\Entity\Post
        comment:    Application\Sonata\NewsBundle\Entity\Comment
        media:      Application\Sonata\MediaBundle\Entity\Media
        user:       Application\Sonata\UserBundle\Entity\User

doctrine:
    orm:
        entity_managers:
            default:
                auto_mapping: false
                #metadata_cache_driver: apc
                #query_cache_driver: apc
                #result_cache_driver: apc
                mappings:
                    SonataNewsBundle: ~
                    ApplicationSonataNewsBundle: ~

Thanks in advance for any help

Polm1 commented 9 years ago

Solved, I post my solution for everyone that will stuck on this issue.

I've managed to this after looking and confronting my project with official sonata sandbox build (2.3 branch), because I suspect that official documentation lacks of some information: https://github.com/sonata-project/sandbox-build

Still I'm not sure which was the specific cause, but after 2 weeks crossing varies versions of sonata bundles I've found these suspect causes

1) in my previous and not working project in AppKernel SonataGridBundle wasn't enabled: the bundle was installed via composer but never enabled

2) in this working project I haven't configured Classification Bundle: just installed via composer, enabled in AppKernel, extended with easy extends and enabled the Extension in AppKernel, stop

3) After extending News Bundle and Classification Bundle, I've found some problems with Application\Resources\config\doctrine.mongodb.xml, I've resolved simply deleting them since I don't use anymore MongoDB with Sonata Bundles (I suspect that still it isn't stable integration)

4) Upgraded db schemes as last part of process after installing every bundle

5) Notice that official documentation shows a little error in advanced config of permalink date: http://sonata-project.org/bundles/news/master/doc/reference/advanced_configuration.html

the row

permalink:
        date:     %%1$04d/%%2$02d/%%3$02d/%%4$s => 2012/02/01/slug

must be

permalink:
        date:     %%1$04d/%%2$02d/%%3$02d/%%4$s

Here are my setup:

***composer.json

"php": ">=5.3.3",

"symfony/symfony": "~2.5",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"symfony/translation": "2.6.*@dev",
"symfony/serializer": "2.6.*@dev",
"symfony-cmf/routing-bundle": "~1.4@dev",

"phpunit/phpunit": "4.0.*",
"twig/extensions": "~1.0",

"sensio/distribution-bundle": "~2.3",
"sensio/framework-extra-bundle": "~3.0",
"sensio/generator-bundle": "~2.3",
"sensio/buzz-bundle": "~1.0@dev",

"jms/di-extra-bundle": "~1.4",
"jms/serializer-bundle": "~0.11",

"incenteev/composer-parameter-handler": "~2.0",
"misd/guzzle-bundle": "~1.0",   
"klaussilveira/neo4j-ogm-bundle": "dev-master",
"craue/formflow-bundle": "2.1.4",
"oyejorge/less.php": "~1.5",
"dsyph3r/google-geolocation-bundle": "*",
"gedmo/doctrine-extensions": "dev-master",
"adesigns/calendar-bundle": "dev-master",
"avalanche/sitemap-bundle": "dev-master",
"willdurand/geocoder-bundle": "@stable",
"thybag/php-sharepoint-lists-api": "dev-master",
"stripe/stripe-php": "1.*",
"mopa/bootstrap-bundle": "~3.0@dev",
"twbs/bootstrap": "~3.3@dev",

"doctrine/orm": "~2.4",
"doctrine/dbal": "~2.4",
"doctrine/doctrine-bundle": "~1.2",
"doctrine/doctrine-migrations-bundle": "~2.0@dev",
"doctrine/migrations": "~1.0@dev",
"doctrine/mongodb-odm": "1.0.*@dev",
"doctrine/mongodb-odm-bundle": "3.0.*@dev",
"doctrine/collections": "dev-protected as 1.2.x-dev",
"doctrine/orm": "2.5.*@dev",

"knplabs/knp-menu-bundle": "~2.0",
"knplabs/gaufrette": "0.1.4",    
"friendsofsymfony/jsrouting-bundle": "1.x-dev",

"sonata-project/datagrid-bundle": "~2.2@dev",
"sonata-project/easy-extends-bundle": "~2.1",
"sonata-project/seo-bundle": "~1",
"sonata-project/doctrine-extensions": "~1@dev",
"sonata-project/intl-bundle": "~2.1",
"sonata-project/admin-bundle": "~2.2",
"sonata-project/doctrine-mongodb-admin-bundle": "2.3.*@dev",
"sonata-project/doctrine-orm-admin-bundle": "~2.2",
"sonata-project/notification-bundle": "~2.2@dev",
"sonata-project/block-bundle": "~2.2",
"sonata-project/media-bundle": "~2.2",
"sonata-project/user-bundle": "~2.2",
"sonata-project/formatter-bundle": "~2.3",
"sonata-project/news-bundle": "~2.3",
"sonata-project/classification-bundle": "~2.2"

*\ AppKernel related to Sonata and dependincies

//SYMFONY BUNDLES
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle(),
new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle() ,

//SENSIO BUNDLES
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new Sensio\Bundle\BuzzBundle\SensioBuzzBundle(),

//MISC BUNDLES
new Misd\GuzzleBundle\MisdGuzzleBundle(),
new Neo4j\OGM\OGMBundle\Neo4jOGMBundle(),
new Mopa\Bundle\BootstrapBundle\MopaBootstrapBundle(),
new Craue\FormFlowBundle\CraueFormFlowBundle(),
new Google\GeolocationBundle\GoogleGeolocationBundle(),
new ADesigns\CalendarBundle\ADesignsCalendarBundle(),
new Avalanche\Bundle\SitemapBundle\AvalancheSitemapBundle(),
new Bazinga\Bundle\GeocoderBundle\BazingaGeocoderBundle(),
new Ivory\CKEditorBundle\IvoryCKEditorBundle(), //required by Sonata News Bundle

//DOCTRINE BUNDLES
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle(),
new Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),

//JMS BUNDLES
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
new JMS\AopBundle\JMSAopBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),

//FOS BUNDLES
new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
new FOS\UserBundle\FOSUserBundle(),

//KNP BUNDLES
new Knp\Bundle\MenuBundle\KnpMenuBundle(), 
new Knp\Bundle\MarkdownBundle\KnpMarkdownBundle(), //required by Sonata News Bundle

//SONATA BUNDLES
new Sonata\AdminBundle\SonataAdminBundle(),
new Sonata\DoctrineMongoDBAdminBundle\SonataDoctrineMongoDBAdminBundle(),
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
new Sonata\EasyExtendsBundle\SonataEasyExtendsBundle(),
new Sonata\CoreBundle\SonataCoreBundle(),
new Sonata\IntlBundle\SonataIntlBundle(),
new Sonata\FormatterBundle\SonataFormatterBundle(), //required by Sonata News Bundle
new Sonata\BlockBundle\SonataBlockBundle(),
new Sonata\SeoBundle\SonataSeoBundle(),
new Sonata\DatagridBundle\SonataDatagridBundle(),

//SONATA BUNDLES + EXTENSIONS
new Sonata\UserBundle\SonataUserBundle('FOSUserBundle'),
new Application\Sonata\UserBundle\ApplicationSonataUserBundle(), //userbundle remap postgres

new Sonata\NotificationBundle\SonataNotificationBundle(),
new Application\Sonata\NotificationBundle\ApplicationSonataNotificationBundle(), 

new Sonata\MediaBundle\SonataMediaBundle(),
new Application\Sonata\MediaBundle\ApplicationSonataMediaBundle(),

new Sonata\ClassificationBundle\SonataClassificationBundle(),
new Application\Sonata\ClassificationBundle\ApplicationSonataClassificationBundle(), 

new Sonata\NewsBundle\SonataNewsBundle(),
new Application\Sonata\NewsBundle\ApplicationSonataNewsBundle()

*\ sonata_classification.yml: ABSENT, NOT CONFIGURED

*\ sonata_media.yml

sonata_media:
    db_driver:       doctrine_orm # | doctrine_mongodb
    default_context: default
    contexts:
        default:  # the default context is mandatory
            download:
                mode: http # X-Sendfile | http
            providers:
                - sonata.media.provider.dailymotion
                - sonata.media.provider.youtube
                - sonata.media.provider.image
                - sonata.media.provider.file
                - sonata.media.provider.vimeo

            formats:
                small: { width: 100, quality: 100}
                big:   { width: 970 , quality: 100}

        news:
            providers:
                - sonata.media.provider.image

            formats:
                abstract: { width: 100, quality: 100}
                wide:     { width: 820, quality: 100}

        sonata_collection:
            providers:
              - sonata.media.provider.image

            formats:
                preview: { width: 100, quality: 100}
                wide:    { width: 820, quality: 100}

        sonata_category:
            providers:
              - sonata.media.provider.image

            formats:
                preview: { width: 100, quality: 100}
                wide:    { width: 820, quality: 100}

        sonata_product:
            providers:
                - sonata.media.provider.image

            formats:
                preview:   { width: 100, quality: 100}
                small:     { width: 300, quality: 100}
                large:     { width: 750, quality: 100}

    cdn:
        # define the public base url for the uploaded media
        server:
            path: /uploads/media

    filesystem:
        # define where the uploaded file will be stored
        local:
            directory:  %kernel.root_dir%/../web/uploads/media
            create:     true

    providers:
        # ...
        file:
            # the resizer must be set to false, otherwhise this can delete icon files from the fs
            resizer:    false
        image:
           thumbnail: sonata.media.thumbnail.format          # default value
#           thumbnail: sonata.media.thumbnail.consumer.format # can be used to dispatch the resize action to async task
#            thumbnail: sonata.media.thumbnail.liip_imagine    # use the LiipImagineBundle to resize the image
        vimeo:
            thumbnail: sonata.media.thumbnail.format          # default value
#           thumbnail: sonata.media.thumbnail.consumer.format # can be used to dispatch the resize action to async task
#           thumbnail: sonata.media.thumbnail.liip_imagine    # use the LiipImagineBundle to resize the image
        youtube:
            thumbnail: sonata.media.thumbnail.format          # default value
#           thumbnail: sonata.media.thumbnail.consumer.format # can be used to dispatch the resize action to async task
#           thumbnail: sonata.media.thumbnail.liip_imagine    # use the LiipImagineBundle to resize the image
        dailymotion:
            thumbnail: sonata.media.thumbnail.format          # default value
#           thumbnail: sonata.media.thumbnail.consumer.format # can be used to dispatch the resize action to async task
#           thumbnail: sonata.media.thumbnail.liip_imagine    # use the LiipImagineBundle to resize the image

doctrine:
    orm:
        entity_managers:
            default:
                mappings:
                    SonataMediaBundle: ~
                    ApplicationSonataMediaBundle: ~

    dbal:
        types:
            json: Sonata\Doctrine\Types\JsonType

*\ sonata_news.yml

sonata_news:
    title:        Sonata Project
    link:         http://sonata-project.org
    description:  Cool bundles on top of Symfony2
    salt:         'secureToken'

    # permalink_generator: sonata.news.permalink.category # /party/new-year
    permalink_generator: sonata.news.permalink.date # /2011/12/31/new-year
    permalink:
        date:     %%1$04d/%%2$02d/%%3$02d/%%4$s #date format for slug: => 2012/02/01/slug

    # comment options
    comment:
        notification:
            emails:   [email@example.org, email2@example.org]
            from:     no-reply@sonata-project.org
            template: 'SonataNewsBundle:Mail:comment_notification.txt.twig'

# Enable Doctrine to map the provided entities
doctrine:
    orm:
        entity_managers:
            default:
                mappings:
                    #ApplicationSonataNewsBundle: ~
                    SonataNewsBundle: ~

and last, doctrine orm config from config.yml:

doctrine:
    dbal:
        connections:
            default:
                <your params>
        types:
            json: Sonata\Doctrine\Types\JsonType

    orm:
        auto_generate_proxy_classes: false
        proxy_namespace: Proxies
        proxy_dir: "%kernel.cache_dir%/doctrine/orm/Proxies"
        default_entity_manager: default
        entity_managers:
            default:
                auto_mapping: true
                metadata_cache_driver: array
                query_cache_driver: array
                result_cache_driver: array
                mappings:

Hope this helps in case of need

Polm1 commented 9 years ago

EDIT: I've managed to solve even with admin bundle 2.4 and news bundle 2.4, it seems that only responsible was Classification Bundle, here's my composer:

"knplabs/knp-menu-bundle": "~2.0", "knplabs/gaufrette": "0.1.6",
"friendsofsymfony/jsrouting-bundle": "1.x-dev",

"sonata-project/datagrid-bundle": "~2.2@dev", "sonata-project/easy-extends-bundle": "~2.1", "sonata-project/seo-bundle": "2.0.@dev", "sonata-project/doctrine-extensions": "~1@dev", "sonata-project/intl-bundle": "~2.1", "sonata-project/admin-bundle": "2.4.@dev", "sonata-project/doctrine-mongodb-admin-bundle": "2.3.@dev", "sonata-project/doctrine-orm-admin-bundle": "~2.2", "sonata-project/notification-bundle": "~2.2@dev", "sonata-project/block-bundle": "~2.2", "sonata-project/media-bundle": "2.4.@dev", "sonata-project/user-bundle": "2.3.@dev", "sonata-project/formatter-bundle": "2.4.@dev", "sonata-project/news-bundle": "2.4.*@dev", "sonata-project/classification-bundle": "~2.2"

The only action taken (with previous version of the fix installed) are: 1) Modify existing composer as this and run update 2) re-extend only classification bundle 3) drop and regenerate db + schemas 4) create user to acces admin

Please note that no changes in AppKernel or yml files are required

Hope this helps