Summary
Defaulted the YAML component to use the PECL YAML PHP extension if it is available.
PECL YAML provides a parser(decode) and emitter(encode) implementation using the standards compliant LibYAML used by many languages. Using it provides a significant performance improvement for uncached reads (decoding).
Additionally the included tests provide compliance testing for YAML files in core.
Developer Impact
There is a new entry available in settings.php yaml_parser_class which allows the overriding of the YAML serialization implementation allowing locking to a specific implementation or providing your own. This only affects decoding as encoding always goes through Symfony to provide consistent writes.
Developers will need to replace use statements referencing \Drupal\Component\Serialization\Yaml and \Drupal\Component\Discovery\YamlDiscovery with \Drupal\Core\Serialization\Yaml and \Drupal\Core\Discovery\YamlDiscovery respectively to allow sites to make use of the settings. No change will default to core's logic of defaulting to PECL.
Tests that rely on specific Symfony behaviors like some cases of invalid or quirky YAML behaviors and Symfony specific error messages may fail. Problematic YAML includes:
- Duplicate mapping(hash) entries.
foo: whatever foo: whenever bar: stuffSymfony will use the last entry where PECL will use the first.
- Scalars starting with the invalid character @ or other reserved characters. The current implementation of Symfony allows this to be unquoted for compatibility but future versions do not because it is disallowed by the YAML specification. It is solved simply by quoting the scalar.
foo: "@service"
http://www.yaml.org/spec/1.2/spec.html#id2774058
https://github.com/symfony/symfony/blob/master/UPGRADE-3.0.md#yaml
Comments
Example
If you want to use Symfony default YAML parser. Add this line to your setting.php
Should be default
That should be the default setting. If anyone is having problems with multiline yaml, perhaps see this issue.