[Yaml] Fix for #6498

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes + added regression test
Fixes the following tickets: #6498
Todo: check if this should be done against an older branch, say 2.1/2.0 even
License of the code: MIT
Documentation PR: not needed imho.

I'm not sure if it's the best fix around there so please provide some feedback :)

Thanks!