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

Bug of end of line using Yaml::dump #33464

Closed
abonne01 opened this issue Sep 5, 2019 · 6 comments
Closed

Bug of end of line using Yaml::dump #33464

abonne01 opened this issue Sep 5, 2019 · 6 comments

Comments

@abonne01
Copy link

abonne01 commented Sep 5, 2019

Symfony version(s) affected: 4.3.4
Description
Following correction of bug #32251 (thanks @nicolas-grekas) there is a problem with yaml::dump function when using Tagged value and inline parameter

How to reproduce

    $rootYaml[] = new TaggedValue('group', 'admin');
    $rootYaml[] = new TaggedValue('group', 'admin2');
    $admin = array(
        'role' => new TaggedValue('group', 'admin'),
        'privileges' => array('read', 'create', 'update'),
        'resource' => new TaggedValue('policy', 'root')
    );
    $rootYaml[] = new TaggedValue('permit', $admin);

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

result

- !group
  admin- !group
  admin2- !permit
  role: !group
      admin  privileges:
      - read
      - create
      - update
  resource: !policy
      root

expected result

- !group admin
- !group admin2
- !permit
  role: !group admin  
  privileges:
      - read
      - create
      - update
  resource: !policy root
@xabbuh
Copy link
Member

xabbuh commented Sep 5, 2019

Is this the same as #33354 and thus fixed by #33377?

@abonne01
Copy link
Author

abonne01 commented Sep 5, 2019

Hello,

I applied fixed on my test. it's already much better but doesn't solve completely:
This is result with fix. For me there are now too many end lines.

- !group
  admin
- !group
  admin2
- !permit
  role: !group
      admin
  privileges:
      - read
      - create
      - update
  resource: !policy
      root

@abonne01
Copy link
Author

abonne01 commented Sep 5, 2019

After additional checks, it seems that both syntax are valid (not a yaml expert).
At least, application used (conjur) is accepting both syntax.

I feel that it's more human readable in one line for such cases:

- !group
  admin

or

- !group admin

@xabbuh
Copy link
Member

xabbuh commented Sep 5, 2019

Before the latest release the dumper didn't take the inline argument into account when dumping tagged values. That's the explanation for the difference if I don't miss anything else.

@xabbuh
Copy link
Member

xabbuh commented Sep 9, 2019

@abonne01 I guess #33518 is what you have in mind, right?

@abonne01
Copy link
Author

perfect. #33518 solve issue. Thanks.

fabpot added a commit that referenced this issue Sep 10, 2019
This PR was merged into the 3.4 branch.

Discussion
----------

[Yaml] don't dump a scalar tag value on its own line

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

This commit fine tunes the bugfix made in #33377 with the feedback provided in #33464 (comment).

Commits
-------

a549069 don't dump a scalar tag value on its own line
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

3 participants