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

Exported boolean yaml strings are not quoted consistently #2673

Open
marcvangend opened this issue Mar 15, 2017 · 2 comments
Open

Exported boolean yaml strings are not quoted consistently #2673

marcvangend opened this issue Mar 15, 2017 · 2 comments

Comments

@marcvangend
Copy link

(Excuse me if this is not the right place to ask, I'm not sure if this is a Drush problem.)

When my colleague exports config with drush cex, some strings are quoted. I think I was able to trace this back to \Symfony\Component\Yaml\Escaper::requiresSingleQuoting(), and the behavior seems to make sense because those strings ('null', '~', 'true', 'false', 'y', 'n', 'yes', 'no', 'on', 'off') could otherwise be interpreted as booleans.

Unfortunately the behavior is not consistent across our team. Sometimes the strings are quoted, sometimes they aren't, so we keep polluting the git history with changed config. We have verified that we use the same Drush version (8.1.10) and Composer version (1.3.2). Since we commit our composer.lock file to git, we also use the same packages. We are not on the exact same PHP7 versions, but looking at the code I think that the PHP version should not matter in this case.

What could be the cause of this? What can I do, or what other information could be relevant to figure out why this is happening? Thank you.

@weitzman
Copy link
Member

I am under the vague impression that this can happen when some team members have pecl yaml extension and some don't.

@marcvangend
Copy link
Author

marcvangend commented Mar 18, 2017

Thanks for the tip. I tried to verify on my own machine if this is indeed the problem. It seems that pecl yaml is not the cause; at least it is not with the combination of software versions I tested.

Initial situation:

  • My machine does not have the pecl yaml extension installed
  • I'm running PHP 7.1.2, Drush 8.1.10, Composer 1.3.2, Drupal 8.2.6, symfony/yaml 2.8.17
  • The output of drush cget language.mappings is:
      map:
        no: nb
        pt: pt-pt
        zh: zh-hans
        zh-tw: zh-hant
        zh-hk: zh-hant
        zh-mo: zh-hant
        zh-cht: zh-hant
        zh-cn: zh-hans
        zh-sg: zh-hans
        zh-chs: zh-hans
      _core:
        default_config_hash: EMWe7Yu4Q5eD-NUfNuQAWGBvYUNZPIinztEtONSmsDc
      langcode: nl
    
  • When my colleague exports language.mappings, the "no" is quoted:
      map:
        'no': nb
        ...
    

What I tried

  • Install the pecl yaml extension, version 2.0.0, with LibYAML version 0.1.7, from my Linux distro's package manager
  • Verify that drush is indeed using php with the yaml extension (drush eval "phpinfo();" | grep -i yaml)
  • Run drush cget language.mappings with default yaml extension options
  • Run drush cget language.mappings with changed yaml extension options (yaml.output_canonical=1, yaml.decode_binary=1, yaml.decode_php=1, yaml.decode_timestamp=1)
  • I have not yet checked

Results so far

  • In all situations, my output remained the same (not quoted)
  • I have not yet checked which extensions are running on my colleagues machine (it's weekend :-))
  • I wanted to test with a different (older) version of the pecl yaml extension, but it was not available in the package manager.

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

2 participants