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
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 2829919-19.patch | 25.35 KB | claudiu.cristea |
Issue fork drupal-2829919
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
Comment #2
andypostMaybe there's a way to prevent use of binary encoding? I mean some setting in SF
FYI
x03originally 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 openComment #4
claudiu.cristeaIMO, we should drop the separator and migrate to a real array, because the plural variants list is an indexed array:
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:
will be encoded as
With current code the above case would be represented as:
EDIT: Changed the proposed schema from mapping to sequence.
Comment #7
sunComment #9
claudiu.cristeaThis 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
PluralTranslatableMarkupis 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.
Comment #11
claudiu.cristeaFixing tests.
Comment #13
claudiu.cristeaMore test fixes.
Comment #14
claudiu.cristeaSplit off #2997100: Introduce a way to deprecate config schemas. Postponing this.
Comment #17
alexpottThis 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.
Comment #18
claudiu.cristeaAs this is blocked on #2997100: Introduce a way to deprecate config schemas and that is
9.1.x, let's move this too.Comment #19
claudiu.cristeaProvided 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.
Comment #20
claudiu.cristeaComment #21
alexpottfor what its worth there is not a way to disable the automatic conversion to use !!binary
Comment #22
claudiu.cristea@alexpott, you mean there could be other circumstances (other than plural variants) that would produce !!binary conversions?
Comment #23
alexpott@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.
Comment #24
claudiu.cristea@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.
Comment #25
alexpott@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.
Comment #26
andypostBlocker commited
Comment #32
wim leersI 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 😳
Comment #33
wim leersOh, 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! 😊🙏
Comment #34
claudiu.cristea@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
Comment #37
claudiu.cristeaHere'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?)
Comment #38
claudiu.cristeaThe whole logic is here https://git.drupalcode.org/project/plural_serialization/-/blob/1.x/src/E...