dustin10 / VichUploaderBundle

A simple Symfony bundle to ease file uploads with ORM entities and ODM documents.
MIT License
1.85k stars 519 forks source link

db_driver: mongodb causes circular reference error in monolog #693

Open kbzowski opened 7 years ago

kbzowski commented 7 years ago

Hello, When db_driver is set to mongodb and monolog handler also uses mongodb circular reference errors appears:

Circular reference detected for service "annotation_reader", path: "cache_warmer -> validator.builder -> annotation_reader -> monolog.logger.cache -> monolog.handler.mongo -> mongolog -> doctrine_mongodb.odm.log_connection".

I can hardly tell if it is the issue with VichUploaderBundle, my configuration or MonologBundle itself, but without any mapping defined in VichUploader - Monolog works fine.

config.yml:

monolog:
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      mongo
        mongo:
            type: mongo
            level: debug
            mongo:
                id: mongolog
                database: logs
                collection: log

vich_uploader:
    db_driver: mongodb
    mappings:
        model_file:
            uri_prefix:         /models
            upload_destination: %kernel.root_dir%/../web/models/
            namer:              vich_uploader.namer_origname
            inject_on_load:     false
            delete_on_update:   true
            delete_on_remove:   true

doctrine_mongodb:
    connections:
        default:
            server: 'mongodb://localhost:27017'
            options: {}
        log:
            server: 'mongodb://localhost:27017'
            options: {}
    default_database: db
    document_managers:
        default:
            auto_mapping: true
            connection: default
        log:
            auto_mapping: false
            logging: false
            connection: log

app/config/services.yml:

services:
    mongolog:
        class: Doctrine\MongoDB\Connection
        factory: ["@doctrine_mongodb.odm.log_connection", getMongoClient]
garak commented 7 years ago

What if you disable mongo handler on monolog and keep vich_uploader enabled?