Problem/Motivation

The \Drupal\Core\StringTranslation\TranslationWrapper was not properly deprecated in 8.x so removal is postponed until 10.0
There's some mentions in database dumps for upgrade tests

Proposed resolution

Deprecate according https://www.drupal.org/core/deprecation#how-class

Remaining tasks

Properly deprecate
Commit

User interface changes

no

API changes

no

Data model changes

no

Release notes snippet

n/a

Comments

Hardik_Patel_12 created an issue. See original summary.

hardik_patel_12’s picture

StatusFileSize
new2.63 KB

Kindly review a patch.

hardik_patel_12’s picture

Status: Active » Needs review
longwave’s picture

Status: Needs review » Reviewed & tested by the community

Two straightforward deprecations, no further deprecated code in this component.

alexpott’s picture

Title: Remove all @deprecated code from StringTranslation component » Properly deprecate \Drupal\Core\StringTranslation\TranslationWrapper
Status: Reviewed & tested by the community » Needs work

I think we need to re-focus this issue to cause a proper deprecation for TranslationWrapper - since, fun fact via @Berdir, it's still present in our database dumps - see what happens if you do gunzip -c core/modules/system/tests/fixtures/update/drupal-8.8.0.bare.standard.php.gz | grep TranslationWrapper

So let's leave the rest of the deprecations here to #3104307: Remove BC layers in various Drupal\Core components and instead add an @trigger_error and derpecate this class for Drupal 10. And work out how to have an upgrade path for things like the our db dumps.

andypost’s picture

It was deprecated in CR https://www.drupal.org/node/2571255 before 8.0, would be great to understand how dumps were populated and why they having it - maybe re-build dump

berdir’s picture

We know why it does, it is part of entity type definitions for example, and no, we don't need to rebuild the dumps because real sites have it too, so our dumps having it is a good thing.

I'm not sure how to get rid of this to be honest. For installed entity type definitions, we can go through them and replace those classes with the undeprecated version. But who knows who else that stuff might be stored.

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new3.07 KB

At least we need to deprecated it properly (guess 10.0.0 is ok here, then it needs 8.8 backport?) and add test

andypost’s picture

StatusFileSize
new872 bytes
new3.05 KB

Fix copy/paste test method

andypost’s picture

Probably test should be extended to prove the class works

andypost’s picture

StatusFileSize
new1.09 KB
new3.17 KB

The better one

alexpott’s picture

Status: Needs review » Needs work
+++ b/core/lib/Drupal/Core/StringTranslation/TranslationWrapper.php
@@ -5,7 +5,19 @@
+  /**
+   * {@inheritdoc}
+   */
+  public function __construct($string, array $arguments = [], array $options = [], TranslationInterface $string_translation = NULL) {
+    @trigger_error(__CLASS__ . ' is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use the \Drupal\Core\StringTranslation\TranslatableMarkup class instead. See https://www.drupal.org/node/2571255', E_USER_DEPRECATED);
+    parent::__construct($string, $arguments, $options, $string_translation);
+  }

this isn't a plugin - we can do the deprecation at the top of the class.

andypost’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new2.41 KB
new2.94 KB

Thank you, updated IS and fixed #12

Status: Needs review » Needs work

The last submitted patch, 13: 3114239-13.patch, failed testing. View results

andypost’s picture

So the last patch is wrong because this update dump contains a lot of mentions in entity type definitions and

->values(array(
  'collection' => 'entity.update_backup',
  'name' => 'taxonomy_term.3192f1',
alexpott’s picture

@andypost the last patch is correct. It shows that in order to deprecate TranslationWrapper we have to somehow fix the entries in the state tables as we're still using it.

andypost’s picture

@alexpott as I see in related dumps were created from 8-rc1 profile very probably on cache clear definitions are not updated

Probably it needs to upgrade dumps and write some update hook to check that definitions using to store TranslatableMarkup

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new1.91 KB
new3.66 KB

This update works but needs tests and still fail of the test

Entity backups also could be fixed, stub as TODO

Status: Needs review » Needs work

The last submitted patch, 18: 3114239-18.patch, failed testing. View results

berdir’s picture

IMHO we should split up the deprecation change and getting rid of usages. Getting rid of the D9 deprecation is kinda beta-blocking, but once we change it to D10, it no longer is. So I'd propose to go with a minimal patch here.

That could be #11, or it could just be the existing description.

alexpott’s picture

@Berdir #11 is not a good because adding a deprecation message to the constructor. I think what we should do here is to change the message to deprecate in D10 and file a follow-up to do #20.

berdir’s picture

I'm fine with either option, adding the message to the constructor or just the minimal part of changing the message. To me, adding it at least to the constructor allows us to warn on new uses of the class, where it's actually being instantiated. There aren't many of them but a few are still there: http://grep.xnddx.ru/search?text=new%20TranslationWrapper. And then we can move it outside when we eventually got rid of the serialized ones too.

And unless we do that by messing with the serialized strings, we'll need to load those objects so we can get rid of them, thereby triggering the deprecation. But then again, that's expected from update functions, that they sometimes need to trigger deprecated code. But it also means we'll need to those update functions into D9.x early enough to be able to remove them again if we want to have a chance for removing the class in D10.

andypost’s picture

I wanted to file follow-up to decide about clean-up, I stuck on finding more places where serialised classes could live in database

+1 to option where it will be less noisy because clean-up of serialisation could be tricky if we allow replacement for igbinary for example.

Moreover the trick with get/set maybe be not allowed for other places (outside of state)

alexpott’s picture

@Berdir great point about the constructor deprecation and contrib. So yeah let's do #11 but we need a follow up to do #18 and move the deprecation to the class's MAIN section.

andypost’s picture

Filed follow-up for #18 #3115726: Clean-up usage of serialized TranslationWrapper from database

move the deprecation to the class's MAIN section.

I did not get it

andypost’s picture

Status: Needs work » Needs review

For 11

alexpott’s picture

#11 looks great. But it should be the last patch on the issue.

andypost’s picture

StatusFileSize
new3.17 KB

re-upload 11

alexpott’s picture

Status: Needs review » Reviewed & tested by the community

@andypost thanks this looks great. I think we should also consider this for 8.9.x too.

catch’s picture

Only concern with this issue is it seems like we can't actually remove it in 10.0.x for similar reasons to not being able to do so here - i.e. it's stored in the database, so until we resolve that it's not entirely deprecated.

Maybe just a follow-up to discuss that issue a bit though?

andypost’s picture

@catch I filled follow up for that in #25

  • catch committed d185342 on 9.0.x
    Issue #3114239 by andypost, Hardik_Patel_12, alexpott, Berdir: Properly...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Oh good point. In that case.

Committed d185342 and pushed to 9.0.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.