Problem/Motivation

Opening this from #2712647: Update Symfony components to ~3.2.

+++ b/core/modules/file/config/optional/views.view.files.yml
@@ -565,7 +565,7 @@ display:
-          format_plural_string: "1 place\x03@count places"
+          format_plural_string: !!binary MSBwbGFjZQNAY291bnQgcGxhY2Vz

@@ -1007,7 +1007,7 @@ display:
-          format_plural_string: "1\x03@count"
+          format_plural_string: !!binary MQNAY291bnQ=

Symfony 3.1 introduces automatic binary encoding. Our format plural uses the x03 escape character as a separator, this results in the diff above, which is not an improvement.

Additionally, the only test coverage we have of this is due to views.views.files.yml - if for some reason that stopped using format plural we'd not have noticed the change in behaviour. This wouldn't have been a bug as such, but it means diffs between YAML output from pecl_yaml vs. symfony as well as vs. YAML that's imported, exported, then exported again.

Proposed resolution

Consider using a different separator that doesn't result in binary encoding, so that YAML files remain human-readable/writable (which was supposed to be the point of using YAML in the first place).

If for some reason that's not possible, add a test configuration file (could be a copy of views.view.files.yml) so the behaviour we have is documented. Even if we do make the change we could have a test YAML file with format plural usage.

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork drupal-2829919

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:

Comments

catch created an issue. See original summary.

andypost’s picture

Maybe there's a way to prevent use of binary encoding? I mean some setting in SF

FYI x03 originally this comes from #532512: Plural string storage is broken, editing UI is missing and #851362: Add hash column to {locales_source} to query faster locale strings still open

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

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

claudiu.cristea’s picture

IMO, we should drop the separator and migrate to a real array, because the plural variants list is an indexed array:

Now Proposed
Schema
# String containing plural variants,
separated by EXT.
plural_label:
  type: label
  label: 'Plural variants'
Schema
# List of plural variants.
plural_label:
  type: sequence
  label: 'Plural variants'
  sequence:
    type: label
    label: 'Plural variant'
Example
format_plural_string: "1 place\x03@count places"
Example
format_plural_string:
  - '1 place'
  - '@count places'

The YAML encoder knows to deal with cases when a variant is missing. For example the Romanian language has 3 plural variants but if a variant, for some reasons, is missing, the encoder will preserve the deltas:

[
  0 => '1 loc',
  // The 2nd variant is missed.
  2 =>  '@count de locuri',
]

will be encoded as

format_plural_string:
  0: '1 loc'
  2: '@count de locuri'

With current code the above case would be represented as:

format_plural_string: "1 loc\x03\x03@count de locuri"

EDIT: Changed the proposed schema from mapping to sequence.

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.

sun’s picture

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.

claudiu.cristea’s picture

Status: Active » Needs review
StatusFileSize
new25.36 KB

This is a first POC patch based on the idea from #4. Note that only the plural label storage in config entities is covered here. The handling of plurals by PluralTranslatableMarkup is left untouched, to be eventually discussed in a followup.

EDIT: Also this is proposing a way to deprecate config schemas, which probably needs an approval first as policy.

Status: Needs review » Needs work

The last submitted patch, 9: 2829919-9.patch, failed testing. View results

claudiu.cristea’s picture

Status: Needs work » Needs review
StatusFileSize
new33.06 KB
new8.71 KB

Fixing tests.

Status: Needs review » Needs work

The last submitted patch, 11: 2829919-11.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

claudiu.cristea’s picture

Status: Needs work » Needs review
StatusFileSize
new29.53 KB
new5.54 KB

More test fixes.

claudiu.cristea’s picture

Status: Needs review » Postponed
Related issues: +#2997100: Introduce a way to deprecate config schemas

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.

alexpott’s picture

This change will require changes to the POTX module as that's designed to find plural delimiters in config strings - see https://git.drupalcode.org/search?utf8=%E2%9C%93&snippets=&scope=&reposi...

This fix is tricky - I'm not sure that changing this to an array is going to be simple.

claudiu.cristea’s picture

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

As this is blocked on #2997100: Introduce a way to deprecate config schemas and that is 9.1.x, let's move this too.

claudiu.cristea’s picture

Status: Postponed » Needs review
StatusFileSize
new29.06 KB
new12.06 KB
new25.35 KB

Provided a patch on top of #2997100: Introduce a way to deprecate config schemas just to see the tests. Will take a look at potx module.

claudiu.cristea’s picture

Status: Needs review » Postponed
alexpott’s picture

for what its worth there is not a way to disable the automatic conversion to use !!binary

claudiu.cristea’s picture

@alexpott, you mean there could be other circumstances (other than plural variants) that would produce !!binary conversions?

alexpott’s picture

@claudiu.cristea I mean there's no obvious way of handling our use-case and keeping the single string with the separator without doing upstream (i.e. Symfony) work.

claudiu.cristea’s picture

@alexpott, for me it’s more than the binary encoding issue. On a YAML serialization we are serializing twice the plural label, once with our concatenation array serializer and then with the YAML one. The same happens with the PHP or any other serializer. In fact, as the plural label is an indexed array, any serialializer on Earth knows how to serialize it. A human, inspecting a YAML file is more familiar with a sequence comparing to a concatenated string. I’ve already discussed this with Gabor in #2765065-10: Allow plurals on bundle labels.

alexpott’s picture

@claudiu.cristea I agree but that's a big step for POTX to take - it needs to find these special arrays and process them accordingly. And making change in POTX and re has always proven tricky.

I think your solution of actually using an array is probably the correct one - but it means we've got a lot of work to get all the moving parts to move at the right time.

andypost’s picture

Status: Postponed » Needs work

Blocker commited

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.

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.

wim leers’s picture

I definitely like the before vs after in the change record 🤩

Looks like the necessary changes in POTX are the hard blocker here. But … where does that code live? 😅 I guess I've been lucky to not have to deal with that in 15 years of contributing to Drupal 😳

wim leers’s picture

Issue tags: +Configuration schema

Oh, and excellent work on #2997100: Introduce a way to deprecate config schemas, even if this did not yet land, #2997100 alone is a super valuable contribution! 😊🙏

claudiu.cristea’s picture

@Wim Leers

> Looks like the necessary changes in POTX are the hard blocker here. But … where does that code live?

here -> https://www.drupal.org/project/potx

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.

claudiu.cristea’s picture

Here's a module that might save anyone who want clean plural variants in the exported YAML: https://www.drupal.org/project/plural_serialization

(maybe the idea could be moved in core?)

claudiu.cristea’s picture

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.