Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yaml dump : ignore inline parameter when TaggedValue used #32251

Closed
abonne01 opened this issue Jun 28, 2019 · 3 comments
Closed

Yaml dump : ignore inline parameter when TaggedValue used #32251

abonne01 opened this issue Jun 28, 2019 · 3 comments

Comments

@abonne01
Copy link

Symfony version(s) affected: symfony/yaml 4.3

Description

I have an issue with Yaml::Dump() function.
when I use TaggedValue, dump function is ignoring parameter $inline

How to reproduce

       $rootYaml = array();
        foreach ($Admins as $Admin) {
            $adm = array(
                'id' => $Admin['samaccountname'][0],
                'annotations' => array(
                    'name' => $Admin['cn'][0],
                    'email' => $Admin['mail'][0]
            ));
            $rootYaml[] = new TaggedValue('user', $adm);
        }

        $value = Yaml::dump($rootYaml, 3);

I would expect to have

- !user 
  id: user1, 
  annotations: 
    name: 'Louisa Nicolas'
    email: mail@domain.com
- !user
  id: user2
  annotations: 
    name: 'Telper Max'
    email: mail@domain.com 

but it's returning

- !user { id: user1, annotations: { name: 'Louisa Nicolas', email: mail@domain.com } }
- !user { id: user2, annotations: { name: 'Telper Max', email: mail@domain.com } }

Possible bug location
comming from Dumper.php, line 58 on if condition
if ($inline <= 0 || !\is_array($input) || empty($input)) {

@fluchi
Copy link

fluchi commented Jul 2, 2019

Hi,

I've created a reproducer for this issue:
https://github.com/fluchi/symfony-issue-32251

The reproducer has a command called dump:yaml, it'll dump file with different inline parameters and also will do a diff between them.
Diff will return the difference between yaml files not using TaggedValue, in another hand, nothing will be returned when TaggedValue is used.

thanks

@abonne01
Copy link
Author

abonne01 commented Jul 4, 2019

thanks for that. I will continue to follow this issue

@xabbuh
Copy link
Member

xabbuh commented Jul 23, 2019

see #32688

nicolas-grekas added a commit that referenced this issue Jul 24, 2019
…buh)

This PR was merged into the 3.4 branch.

Discussion
----------

[Yaml] fix inline handling when dumping tagged values

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #32251
| License       | MIT
| Doc PR        |

Commits
-------

07590ae fix inline handling when dumping tagged values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants