Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When an PluralTranslatableMarkup
object is serialized, count field disappears from it.
Comment | File | Size | Author |
---|---|---|---|
#13 | 2844181-13.patch | 2.24 KB | alexpott |
#13 | 2844181-13.test-only.patch | 1.7 KB | alexpott |
#11 | 2844181-10.patch | 1.43 KB | maxocub |
#11 | 2844181-10-test-only.patch | 914 bytes | maxocub |
#2 | drupal-plural-translatable-markup-serialization-2844181-2-D8.patch | 546 bytes | Alex Bukach |
Comments
Comment #2
Alex Bukach CreditAttribution: Alex Bukach commentedHere's the patch that overrides the parent
__sleep
method.Comment #3
Wim LeersThanks!
Should also document why
translatedString
does not also need to be serialized.I'm tempted to say this needs test coverage, but it seems excessive for something as trivial as this.
Comment #4
Alex Bukach CreditAttribution: Alex Bukach commentedWim, thanks for the quick review.
Regarding
translatedString
, it's reset when the object is rendered. Any argument why we should preserve the originaltranslatedString
?Comment #5
Gábor HojtsyYeah this looks like a total oversight. translatedString is computed I believe at all times, so it should not be / don't need to be serialized.
Comment #6
Gábor HojtsyRe tests, I agree "seems excessive for something as trivial as this.". So let's get this in then :)
Comment #7
Wim LeersYay :)
Comment #8
alexpottHmmm... I would have thought that we occasionally serialize these in form state and the like. Also I really do think this should be tested. It'd be easy to remove this code without it. Consider the following code:
Comment #9
Alex Bukach CreditAttribution: Alex Bukach commentedI agree, we need also tests.
Comment #10
Alex Bukach CreditAttribution: Alex Bukach commentedActually I failed to figure out how to write the test for this case and whether it's possible. If it is, is IRC an appropriate place to ask for a hint?
Comment #11
maxocub CreditAttribution: maxocub commented@Alex Bukach: I think that alexpott's code sample can be used to test this. I'm not sure were we should put this test though.
Comment #12
alexpottThere's no need for this to be a WebTestBase test... also this is a core object not a Locale module object. Should be a new unit test in core/tests/Drupal/Tests/Core/StringTranslation. Also should use a data provider and expected text.
Comment #13
alexpottHere's what I mean in patch form.
The test only patch is the interdiff to #2.
Comment #16
Gábor HojtsyLooks great :) Woot :)
Comment #17
alexpottCommitted and pushed 87c1e2e to 8.4.x and 1fbf3db to 8.3.x and 15d68a7 to 8.2.x. Thanks!
I only added the unit test and not the fix so I think it is okay for me to commit this fix.
Comment #21
Gábor HojtsyWoot!
Comment #23
maxocub CreditAttribution: maxocub as a volunteer and commented