khepin / KhepinYamlFixturesBundle

Easy loading of fixtures defined in YAML files for Symfony2 and Doctrine2
MIT License
58 stars 42 forks source link

Warning: Illegal string offset 'model' in v.1.0.0 when loading fixtures #62

Closed dmytro-pro closed 7 years ago

dmytro-pro commented 8 years ago

Hi! I just tried to use this bundle in my project, and found this error:

$ console khepin:yamlfixtures:load

[Symfony\Component\Debug\Exception\ContextErrorException] Warning: Illegal string offset 'model'

Exception trace: () at /var/www/my_app/vendor/khepin/yaml-fixtures-bundle/Khepin/YamlFixturesBundle/Loader/YamlLoader.php:112 Symfony\Component\Debug\ErrorHandler->handleError() at /var/www/my_app/vendor/khepin/yaml-fixtures-bundle/Khepin/YamlFixturesBundle/Loader/YamlLoader.php:112 Khepin\YamlFixturesBundle\Loader\YamlLoader->loadFixtures() at /var/www/my_app/vendor/khepin/yaml-fixtures-bundle/Khepin/YamlFixturesBundle/Command/FixturesLoadCommand.php:66 ...

I have investigated what's the problem, and found a weird place in vendor/khepin/yaml-fixtures-bundle/Khepin/YamlFixturesBundle/Loader/YamlLoader.php:107

$fixture_data = Yaml::parse($file);

After I changed it to

$fixture_data = Yaml::parse(file_get_contents($file));

it worked as expected.

Is this some kind of mistake, or is it just caused by different versions of Yaml component - anyways it's more clear to pass the file data than file name. Could You fix it please? I have found it in both 1.0.0 and 0.8.1 versions, so my pull request is not the best way to do it for all versions.

Thank You!

khepin commented 8 years ago

Hi, you mention a pull-request in your comment but I don't see any. If you have something to submit, that would be the easiest. I'd be happy to review what you have and see if something needs to be merged.

stphane commented 7 years ago

Hello ! I'm having the exact same problem. Fix seems so straight forward but there hasn't be any one released yet, isn't it ? Thank You!

khepin commented 7 years ago

Hey @stphane do you by chance have a fix? I'd be happy to merge a pull request fixing the issue if you could make one.

Do you think that's possible?

stphane commented 7 years ago

@khepin Actualy, dimitry-pro gave the fix already, I expected a new revision to come to life with the following changes in khepin/yaml-fixtures-bundle/Khepin/YamlFixturesBundle/Loader/YamlLoader.php on line 107 (v1.0.0):
$fixture_data = Yaml::parse($file); been replaced by
$fixture_data = Yaml::parse(file_get_contents($file));

khepin commented 7 years ago

Alright, since it's all there then, would you mind making an actual pull request for it? That'll help immensely.

Thanks

stphane commented 7 years ago

Code is okey on master branch since 5th Dec 2015. @khepin Does it make sense to add a fix on 1.0.0 ?

khepin commented 7 years ago

Oh! Gotcha. I never realized the code was already fixed and the only thing needed was a version push. I'll work on that now.

khepin commented 7 years ago

Alright, I've spent the afternoon trying to make those tests pass on Travis and all I get is a composer memory error. Can't figure it out, any help on this one is welcome.

stphane commented 7 years ago

Great ! Concerning the memory error, does your php cli have xdebug enabled ? I had memory issues at some point and disabling the extension did help !

khepin commented 7 years ago

try it and let me know