diff --git a/core/lib/Drupal/Component/Serialization/Yaml.php b/core/lib/Drupal/Component/Serialization/Yaml.php index c129305..94efdd6 100644 --- a/core/lib/Drupal/Component/Serialization/Yaml.php +++ b/core/lib/Drupal/Component/Serialization/Yaml.php @@ -25,6 +25,10 @@ class Yaml implements SerializationInterface { * {@inheritdoc} */ public static function encode($data) { + // Instead of using \Drupal\Component\Serialization\Yaml::getSerializer(), + // always using Symfony for writing the data, to reduce the risk of having + // differences if different environments (like production and development) + // do not match in terms of what YAML implementation is available. return YamlSymfony::encode($data); } @@ -44,12 +48,13 @@ public static function getFileExtension() { } /** - * Determines the optimal implementation to use for encoding and parsing YAML. + * Determines which implementation to use for parsing YAML. */ protected static function getSerializer() { if (!isset(static::$serializer)) { - // Use the PECL YAML extension if it is available. + // Use the PECL YAML extension if it is available. It has better + // performance for file reads and is YAML compliant. if (extension_loaded('yaml')) { static::$serializer = YamlPecl::class; }