sonata-project / SonataMediaBundle

Symfony SonataMediaBundle
https://docs.sonata-project.org/projects/SonataMediaBundle
MIT License
451 stars 495 forks source link

Empty list after uploading #643

Closed robhunt3r closed 8 years ago

robhunt3r commented 10 years ago

When I upload an image, the file is uploaded and shown at upload directory but when I go to /admin/sonata/media/media/list there's one empty row with a checkbox, so I think sonata knows that there's an element but nothing is shown, no name, no description, no size... All empty.

I'm using PHPCR with some PR fixes #638 and #637 in order to make PHPCR work with this bundle.

here's my config

sonata_media:
    db_driver:       doctrine_phpcr #doctrine_phpcr # | doctrine_mongodb
    default_context: default
    class:
        media: Application\Sonata\MediaBundle\PHPCR\Media
        gallery: Application\Sonata\MediaBundle\PHPCR\Gallery
        gallery_has_media: Application\Sonata\MediaBundle\PHPCR\GalleryHasMedia
    contexts:
        default:  # the default context is mandatory
            download:
                mode: http # X-Sendfile | http
            providers:
                - sonata.media.provider.youtube
                - sonata.media.provider.image
                - sonata.media.provider.file

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

    cdn:
        # define the public base url for the uploaded media
        server:
            #path:      %sonata_media.cdn.host%
            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

    pixlr:
        enabled:  false
        referrer: Demo - Sonata Project

    resizer:
        simple:
#            mode:  outbound
            mode:  inset
doctrine_phpcr:
    odm:
        auto_mapping: true
        mappings:
            ApplicationSonataMediaBundle:
                prefix: Application\Sonata\MediaBundle\PHPCR

captura de pantalla de 2014-10-18 17 25 27

robhunt3r commented 10 years ago

EDIT

Previous solution was OK but messy, this solution makes more sense and it isn't that hard.

Just add this to your SonataMedia config:

doctrine_phpcr:
    odm:
        auto_mapping: true
        mappings:
            ApplicationSonataMediaBundle:
                prefix: Application\Sonata\MediaBundle\PHPCR
            SonataMediaBundle:
                prefix: Sonata\MediaBundle\PHPCR

This way it will load correct superclass mappings. Remember to fix #637 and #638 otherwise you will get errors

robhunt3r commented 10 years ago

I've found another issue realted to Gallery stuff. With PHPCR we can't create a gallery, even if it onlny contains it's name (without media)

Error is not descriptive, there's nothing inside logs (this is annoying because just a few stuff or nothing is logged at least when using PHPCR which drives me nuts).

An error has occurred during the creation of item "test".

INFO - Matched route "admin_sonata_media_gallery_create" (parameters: "_controller": "Sonata\MediaBundle\Controller\GalleryAdminController::createAction", "_sonata_admin": "sonata.media.admin.gallery", "_sonata_name": "admin_sonata_media_gallery_create", "_route": "admin_sonata_media_gallery_create")
DEBUG - Read SecurityContext from the session
DEBUG - Reloading user from user provider.
DEBUG - SELECT t0.username AS username_1, t0.username_canonical AS username_canonical_2, t0.email AS email_3, t0.email_canonical AS email_canonical_4, t0.enabled AS enabled_5, t0.salt AS salt_6, t0.password AS password_7, t0.last_login AS last_login_8, t0.locked AS locked_9, t0.expired AS expired_10, t0.expires_at AS expires_at_11, t0.confirmation_token AS confirmation_token_12, t0.password_requested_at AS password_requested_at_13, t0.roles AS roles_14, t0.credentials_expired AS credentials_expired_15, t0.credentials_expire_at AS credentials_expire_at_16, t0.created_at AS created_at_17, t0.updated_at AS updated_at_18, t0.date_of_birth AS date_of_birth_19, t0.firstname AS firstname_20, t0.lastname AS lastname_21, t0.website AS website_22, t0.biography AS biography_23, t0.gender AS gender_24, t0.locale AS locale_25, t0.timezone AS timezone_26, t0.phone AS phone_27, t0.facebook_uid AS facebook_uid_28, t0.facebook_name AS facebook_name_29, t0.facebook_data AS facebook_data_30, t0.twitter_uid AS twitter_uid_31, t0.twitter_name AS twitter_name_32, t0.twitter_data AS twitter_data_33, t0.gplus_uid AS gplus_uid_34, t0.gplus_name AS gplus_name_35, t0.gplus_data AS gplus_data_36, t0.token AS token_37, t0.two_step_code AS two_step_code_38, t0.id AS id_39 FROM fos_user_user t0 WHERE t0.id = ? LIMIT 1 
Context: [1]
DEBUG - Username "admin" was reloaded from user provider.
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\FragmentListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "FOS\RestBundle\EventListener\BodyListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\TranslatorListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Doctrine\Bundle\PHPCRBundle\EventListener\LocaleListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Cmf\Bundle\CoreBundle\EventListener\PublishWorkflowListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\AsseticBundle\EventListener\RequestListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Knp\Bundle\MenuBundle\EventListener\VoterInitializerListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Nelmio\ApiDocBundle\EventListener\RequestListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Cmf\Bundle\SeoBundle\EventListener\ContentListener::onKernelRequest".
DEBUG - Notified event "kernel.controller" to listener "FOS\RestBundle\EventListener\ParamFetcherListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "FOS\RestBundle\EventListener\ViewResponseListener::onKernelController".
WARNING - Translation not found. 
Context: {"id":"Gallery","domain":"SonataMediaBundle","locale":"en"}
WARNING - Translation not found. 
Context: {"id":"Options","domain":"SonataMediaBundle","locale":"en"}
DEBUG - SELECT 1 FROM phpcr_workspaces WHERE name = ? 
Context: ["default"]
DEBUG - "START TRANSACTION"
DEBUG - SELECT * FROM phpcr_nodes WHERE path = :path AND workspace_name = :workspace ORDER BY depth, sort_order ASC 
Context: {":path":"/cms/gallery-has-media",":pathd":"/cms/gallery-has-media/%",":workspace":"default"}
DEBUG - "ROLLBACK"
WARNING - Translation not found. 
Context: {"id":"Gallery","domain":"SonataMediaBundle","locale":"en"}
WARNING - Translation not found. 
Context: {"id":"Options","domain":"SonataMediaBundle","locale":"en"}
WARNING - Translation not found. 
Context: {"id":"default_small","domain":"messages","locale":"en"}
WARNING - Translation not found. 
Context: {"id":"default_big","domain":"messages","locale":"en"}
WARNING - Translation not found. 
Context: {"id":"sonata_content","domain":"ViralMainBundle","locale":"en"}
WARNING - Translation not found. 
Context: {"id":"dashboard.label_game_content","domain":"ViralGameBundle","locale":"en"}
WARNING - Translation not found. 
Context: {"id":"sonata_routing","domain":"ViralMainBundle","locale":"en"}
WARNING - Translation not found. 
Context: {"id":"sonata_menu","domain":"ViralMainBundle","locale":"en"}
WARNING - Translation not found. 
Context: {"id":"sonata_content","domain":"ViralMainBundle","locale":"en"}
WARNING - Translation not found. 
Context: {"id":"dashboard.label_game_content","domain":"ViralGameBundle","locale":"en"}
WARNING - Translation not found. 
Context: {"id":"sonata_routing","domain":"ViralMainBundle","locale":"en"}
WARNING - Translation not found. 
Context: {"id":"sonata_menu","domain":"ViralMainBundle","locale":"en"}
WARNING - Translation not found. 
Context: {"id":"An error has occurred during the creation of item \"test\".","domain":"SonataAdminBundle","locale":"en"}
DEBUG - Write SecurityContext in the session
DEBUG - Notified event "kernel.response" to listener "Symfony\Component\Security\Http\Firewall\ContextListener::onKernelResponse".
DEBUG - Notified event "kernel.response" to listener "FOS\RestBundle\EventListener\AllowedMethodsListener::onKernelResponse".
DEBUG - Notified event "kernel.response" to listener "Sonata\BlockBundle\Cache\HttpCacheHandler::onKernelResponse".
DEBUG - Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ResponseListener::onKernelResponse".
DEBUG - Notified event "kernel.response" to listener "Symfony\Component\Security\Http\RememberMe\ResponseListener::onKernelResponse".
DEBUG - Notified event "kernel.response" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\CacheListener::onKernelResponse".
DEBUG - Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelResponse".
DEBUG - Notified event "kernel.response" to listener "Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener::onKernelResponse".
DEBUG - Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\StreamedResponseListener::onKernelResponse".
DEBUG - Notified event "kernel.finish_request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelFinishRequest".
DEBUG - Notified event "kernel.finish_request" to listener "Symfony\Component\HttpKernel\EventListener\TranslatorListener::onKernelFinishRequest".
DEBUG - Notified event "kernel.finish_request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelFinishRequest".
DEBUG - Notified event "kernel.finish_request" to listener "Symfony\Component\Security\Http\Firewall::onKernelFinishRequest".

I will look further, right now there are problems with PHPCR mappings, which I've solved (I will make a PR when everything works) but it's so frustrating that we can't make MediaBundle work out of the box with PHPCR.

Why am I trying to use Gallery? In order to create a custom content which contains many images, the best way to do it is using a gallery attached to it, otherwise I would need to create custom fields and forms to add multiple medias to it. Gallery has that function built in so I think it's a waste of time.

Any clue on this? Someone is working with PHPCR without problems?

core23 commented 8 years ago

This issue is very old. Can you please check this against the latest master version?

Feel free to reopen if this error still exists.