Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
base system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
11 Mar 2022 at 17:49 UTC
Updated:
8 Apr 2024 at 08:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
longwaveComment #4
longwaveSo we still have lots of references to TranslationWrapper in the 9.3.0 dumps used for update tests:
If we have these here, it seems likely that end users with old sites might still have these references in their database? Do we need to figure out where these might exist and write an update hook to try and get rid of them? Otherwise, sites will crash when unserializing any data that still contains this class.
Or maybe the easiest solution is just to leave this in place forever?
Comment #5
andypostAs I see it's used in serialised data, so it needs update hook to update all data?
Comment #11
longwave> As I see it's used in serialised data, so it needs update hook to update all data?
The problem is that we don't know where this could be. Serialised translatable strings could be hiding anywhere, and I'm not sure we could write an update hook to catch them all.
One solution might be just to class_alias TranslatableMarkup to TranslationWrapper and leave it for backward compatibility?
Comment #12
andypostComment #13
catchAgreed with aliasing. If we want to remove the alias, we can try again later. All the cases I could find from manually reviewing the database dump looked like the installed entity definitions in key_value. Opened a follow-up for that specific case at #3284461: Installed entity definitions in key/value use deprecated TranslationWrapper in database dumps, but even once we've done that, we need to keep the alias in the version until after that update has definitely run.
Comment #14
longwaveThis patch deletes the TranslationWrapper class, adds an alias instead, and recycles the legacy test to test the alias.
Comment #15
longwaveUpdated IS for new approach.
Comment #16
andypost@longwave Nice approach! and no longer need to change all dumps
Comment #18
catchWhoops I just committed this from needs review, misread #16 as an RTBC. But yes this looks good and we can look into removing the alias in Drupal 11 or later.
Comment #20
alexpottThis is kinda tricky because just aliasing the class means that using it will no longer trigger deprecation errors. So in some ways we're in a better place with HEAD. One thing we could try is only making the alias available during update. Do we know which tables are still using it? It is in state because that's going to be trickier to update.
Comment #21
longwaveYes it's in state -
entity.definitions.installedandentity.update_backupin drupal-9.3.0.bare.standard.php.gz (and the same in filled)My worry is that these are deliberately clean databases; we can't be sure where else serialized versions of this object may be hiding in real databases that have been around for a long time. Contrib or custom code could have been using this deprecated class any time, at least until it was properly deprecated and that was only in 2020 in #3114239: Properly deprecate \Drupal\Core\StringTranslation\TranslationWrapper. So my thinking here was just to retain this class_alias forever, as reducing it to one line and test is no real maintenance burden and it won't be used except to retain backward compatibility.
Comment #22
alexpottLet's add an example of where this might occur. I think that is a useful justification to maintaining this alias forever.
Another interesting impact of this change is that it means we'll have to load TranslatableMarkup on every request. So that means that we'll have to load \Drupal\Component\Render\FormattableMarkup and \Drupal\Component\Render\MarkupInterface too. So all these things would need to go in the classmap in core/composer.json in order to optimise the cached response autoloading. For me this means we could consider just permanently deprecating TranslationWrapper and being done.
Comment #23
catchThis is true, but if contrib/custom code doesn't have usages now, then I don't think it makes it more likely that new ones will be added. Also don't think the deprecation messages will help to remove serialized content - because all our update tests are @legacy anyway.
Comment #24
catchCould we switch TranslationWrapper from @deprecated to @internal with a comment explaining why?
Comment #25
longwaveCan we get away with putting the
class_alias()line in TranslatableMarkup itself, assuming that at least one bit of TranslatableMarkup will have already been used by the time TranslationWrapper is needed?Comment #26
alexpottUnfortunately I don't think we could guarantee that.
Comment #27
andypostAs I see the usage could only happens in dumps and some serialized caches/data when sites upgraded from 8.x to 10.x but that should not happen when 9.x is not skipped in upgrade process
Maybe better just regenerate dumps without it?
Comment #28
catch@andypost I'm not sure that's true. The database fixtures have been created by installing 8.x, running updates, then re-exporting again (up to 9.3.0 so far). This means that the updates have not explicitly removed references to this class during that process.
It's possible that real sites no-longer have the references, but there's not really a way for us to prove this.
Comment #29
catchI keep going around in circles on this issue, I think we should probably do the following:
1. Update the deprecation for removal in drupal:11.0.0 and leave the rest alone for now.
2. Open an issue to try to permanently remove the class if we can - i.e. at least find out why the entity metadata in the dumps never got updated and try to write an update to fix that at least.
Comment #30
catchInstead of re-purposing this issue, opened a spin-off to update the deprecation, then this can stay open for the actual removal/aliasing.
#3295421: Update TranslationWrapper deprecation to removal in 11.0.0.
Comment #31
catchWondered if PHP itself had anything for this, and it does, but... not sure we want to go there https://www.php.net/manual/en/var.configuration.php#ini.unserialize-call...
Comment #32
gábor hojtsyPostponing then to Drupal 11, given #3295421: Update TranslationWrapper deprecation to removal in 11.0.0 landed. Also moving under the Drupal 11 META that I just created.
Comment #33
catchDrupal 11 meta seems correct, but we're going to need some kind of 10.x patch before we can actually remove this due to the serialized PHP, so probably more of a 10.1.x task, re-titling now the other issue is in.
Comment #34
ravi.shankar commentedAdded reroll of patch #14 on Drupal 10.1.x.
Comment #36
quietone commentedCan we have an MR here?
Comment #37
ameymudras commentedAdded a MR and checked for a few more deprecations.
Comment #39
ameymudras commentedComment #40
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue.
While you are making the above changes, we recommend that you convert this patch to a merge request. Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)
Comment #41
andypostComment #42
andypostComment #44
smustgrave commentedRemoval of TranslationWrapper seems fine and didn't cause any issues
Changed the title to #32 as seems to more match what's happening here now.
Comment #45
longwaveI am not sure that this is a better solution than what we already have. The class alias will be set up on all sites, and we assume that only a very small number of sites actually need this - but we can't get rid of it entirely if it is serialised in unknown places - so isn't it better off left to the autoloader for those sites, but where it won't be loaded at all in the majority case?
Comment #46
alexpottCommitted 6a9e301 and pushed to 11.x. Thanks!