Problem/Motivation

We have \Drupal\Core\Serialization\Yaml and \Drupal\Component\Serialization\Yaml.

The Core extends the Component class to add the ability to force via a setting yaml_parser_class. The problem is that this setting does not affect all yaml parsing. For example, \Drupal\Component\Discovery\YamlDirectoryDiscovery. This is because YamlDirectoryDiscovery is a component too and therefore shouldn't depend on core code.

Proposed resolution

Remove this unnecessary complexity. At the moment if you the PECL Yaml extension installed it will use it unless this setting is set to use the Symfony class. We should not have set-ability in Drupal. The set-ability should just be determined by whether you have the extension or not.

Remaining tasks

  1. Create change record
  2. Add deprecate notice to code
  3. Replace all usages in core

User interface changes

None

API changes

Deprecating \Drupal\Core\Serialization\Yaml in favour of \Drupal\Component\Serialization\Yaml

Data model changes

None

Issue fork drupal-2880280

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexpott created an issue. See original summary.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

bradjones1’s picture

Title: Deprecate \Drupal\Core\Serialization\Yaml » \Drupal\Core\Serialization\Yaml is dead code, remove it

This class was added in #1920902: Add a Drupal Yaml wrapper so we can default to PECL Yaml component if it is available but the only file touched in that diff is the addition of this class. Core, however, uses the component class in its definition (serialization.yaml)

I think there is a use case to be made for being able to set the serializer - which I will lay out in a new ticket. Given the age of this issue, the fact I think this is actually orphaned code from the 8.x development cycle and there may be better ways of doing this - let's see what a straight patch removing it does on tests. I am not sure it would require a CR if it never worked to begin with, but maybe I'm missing something here.

This is all wrong... I was looking for invocations of this method specifically and of course invocations of the core class abound throughout core.

bradjones1’s picture

Status: Active » Needs review

bradjones1’s picture

Status: Needs review » Active
bradjones1’s picture

Title: \Drupal\Core\Serialization\Yaml is dead code, remove it » Deprecate \Drupal\Core\Serialization\Yaml

OK, sorry for the noise. I came here in search of a way to override the serializer, and this is possible via the method proposed for deprecation here. I think container parameters or some other such "more modern" way of expressing the override is better than a setting, but that's beside the main point.

Consider the case where you'd like to employ Yaml custom tags or enable Symfony's built-in tags. You must provide these as flags to the Symfony parser, which is called in the serializer. I don't think either of these functionalities will roll into core, but they're helpful to specific site owners willing to implement the logic locally and own the complexity.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.