Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Image upload error #186

Closed
asamek opened this issue Feb 17, 2014 · 19 comments
Closed

Image upload error #186

asamek opened this issue Feb 17, 2014 · 19 comments

Comments

@asamek
Copy link

asamek commented Feb 17, 2014

I noticed issue connected with uploading image. During editing content I just click image, select image and try to upload it. I got an error. Request is send to:

symfony-cmf/create/image/upload/ckeditor?CKEditor=editor3&CKEditorFuncNum=221&langCode=pl

After that, error occurs. In my dev env I got Property \"parent\" mapped as ParentDocument may not be empty in document of class \"Symfony\\Cmf\\Bundle\\MediaBundle\\Doctrine\\Phpcr\\Image\", class: Doctrine\\ODM\\PHPCR\\Id\\IdException.

Error occurs even on demo page http://cmf.liip.ch/en - thrown error 500.

@dbu
Copy link
Member

dbu commented Feb 21, 2014

@rmsint could you have a look at this one?

@rmsint
Copy link

rmsint commented Feb 21, 2014

will check it this weekend, looks like a PHPCR-ODM mapping issue

@rmsint
Copy link

rmsint commented Feb 22, 2014

I checked this with the cmf sandbox and cannot reproduce the error: during editing content I click image, select the upload tab, select an image and click send to server.

@dbu can you see the error for the cmf.liip.ch/en site? It is an 500 error, however I cannot see more information about it.
@HaGii What versions are you using?

Imho what needs to be checked is why the parent is not set for the Image object. By default it should be set in Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\MediaManager::setDefaults, you could check the configuration of the root path and that it is created. If the error can be reproduced, it can be debugged at the end of that method to see if the parent is set and if not why it isn't set.

@HaGii Did you run the repository initializer? (doctrine:phpcr:repository:init) This also creates the root path for media.

@asamek
Copy link
Author

asamek commented Feb 22, 2014

@rmsint I using symfony-cmf version 1.0.0. In fact, I init dbal:
php app/console doctrine:phpcr:init:dbal
initialize repository:
php app/console doctrine:phpcr:repository:init
and load fixtures:
php app/console doctrine:phpcr:fixtures:load

I'm not sure how could I check the configuration of the root path?

@rmsint
Copy link

rmsint commented Feb 22, 2014

You could check the root is created using the doctrine:phpcr:node:dump command. Or the phpcr shell: https://github.com/phpcr/phpcr-shell

I think the default path is: /cms/media, it should be mentioned somewhere in the reference documentation.

@asamek
Copy link
Author

asamek commented Feb 23, 2014

I checked it, I have /cms/simple root path.

@rmsint
Copy link

rmsint commented Feb 24, 2014

Is that the root path for media? Anyhow, you could check here if a parent is set (probably not) and what path the image has: https://github.com/symfony-cmf/MediaBundle/blob/master/Doctrine/Phpcr/MediaManager.php#L123. Check the value of $path. And see if it starts with the media root path and that this path exists.

@dbu
Copy link
Member

dbu commented Feb 24, 2014

@rmsint did you try with 1.0.0 or the 1.0 branch of the cmf or the
current master? might be we have a bug in the first release?

@rmsint
Copy link

rmsint commented Feb 24, 2014

@dbu I tried with 1.0.0 of the cmf-sandbox. There is indeed a little bug in 1.0.0 of the cmf-sandbox with the security role not being configured yet for uploading. It gives a 404 permission error and not a 500 error as HaGii posted. So that is not related to this and you solved that already in the current master of the media bundle and create bundle. Also checked it with 1.0.0 for the cmf-sandbox and the master branch for the create-bundle and the media bundle.

@asamek
Copy link
Author

asamek commented Feb 24, 2014

@rmsint I'll check value of $path today's evening.

@asamek
Copy link
Author

asamek commented Feb 24, 2014

So, $path is cms/media/file-name.jpg. This path isn't exist in tree. In tree I have:

ROOT:
  cms:
    simple:
      ...
      media:

@rmsint
Copy link

rmsint commented Feb 25, 2014

Ok we found your issue. Now we can try to solve it. Try with this in your config.yml:

# http://symfony.com/doc/master/cmf/reference/configuration/media.html#persistence
cmf_media:
    persistence:
        phpcr:
            media_basepath: /cms/simple/media

And it should be solved.

I think the cause for this could be something we should try to fix or maybe can prevent it from happening or throw a configuration error with directions to solve it.

@HaGii What is your value for cmf_core.persistence.phpcr.basepath and cmf_create.persistence.phpcr.image.basepath? I expect these 2 settings and cmf_media.persistence.phpcr.media_basepath are different. If yes, I think I know how to reproduce the error.

@asamek
Copy link
Author

asamek commented Mar 2, 2014

@rmsint Thanks, I modified my config.yml and I got another issue: Route 'cmf_media_image_display 'notfound', so I imported CmfMediaBundle/Resources/config/routing/image.xml in my routing.yml:

cmf_media_image:
    resource: "@CmfMediaBundle/Resources/config/routing/image.xml"

Now it's working, but I'm not sure if it's good solution, is it?

Parameters:

  • cmf_core.persistence.phpcr.basepath is /cms
  • cmf_create.persistence.phpcr.image.basepath is not definied.

@dbu
Copy link
Member

dbu commented Mar 4, 2014

the MediaBundle install instructions say that you should do this, so yes that sounds right. are there any problems left or does image upload work like this?

@asamek
Copy link
Author

asamek commented Mar 4, 2014

My problem was solved, thanks!

@asamek asamek closed this as completed Mar 4, 2014
@lucasgranberg
Copy link

I have the same problem and it didn't help to set the basepaths. When I tried to check the value of path in mediamanager as @rmsint suggested I noticed that the method setDefaults is never called.

I use "symfony-cmf/media-bundle": "1.1.*@dev"

Edit:
I do the request via sonata adminbundle so my case is not really the same. I use the cmf_media_image form type

@Bomere
Copy link

Bomere commented Sep 11, 2014

I had the same problem (cmf_create_image_upload not found).

The solution was to add the follow lines into my routing.yml

cmf_create_image:
    resource: "@CmfCreateBundle/Resources/config/routing/image.xml"

@dbu
Copy link
Member

dbu commented Sep 11, 2014

is this missing documentation? or just a change between versions?

@Bomere
Copy link

Bomere commented Sep 12, 2014

I didn't see it in configuration but it's my fault ...
I want to go too fast !
http://symfony.com/doc/master/cmf/bundles/create/introduction.html

I'm sorry for the inconvenience.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants