Closed (fixed)
Project:
Drupal core
Version:
8.7.x-dev
Component:
workspaces.module
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
1 Jul 2019 at 16:29 UTC
Updated:
25 Jul 2019 at 17:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
pmelab commentedComment #3
pmelab commentedFirst patch with test case.
Comment #4
amateescu commentedIt took me a while to figure it out, but
extracan be a simple (string) expression instead of an array, in which case it will be added as-is. So we can replace this and the newrevision_tablejoin plugin with'extra' => "$table.langcode = $relationship.langcode",:)Additionally, we need to do this only if the entity type has a
langcodeentity key, so we need to pass the$entity_typeobject fromensureRevisionTable()togetRevisionTableJoin()and only add the extra join condition if$entity_type->hasKey('langcode').Let's move this line under the one which creates the content type, for better readability :)
The test runner executes the
setUp()method for each test method, so this is not needed. This means we can also remove theprotected $languageManagermember added above.Comment #5
pmelab commentedImplemented suggestions by @amateescu. Thanks!
Comment #6
amateescu commentedLooks great :D Let's see if the testbot agrees.
Comment #7
amateescu commentedOk, the testbot is happy, here's also a test-only patch to prove the failure.
Comment #9
amateescu commentedNot sure what happened with the patch from #7, it applies fine locally on both 8.7.x and 8.8.x, let's try again :)
Edit: Oh, I queued that test on the Drupal 7.x branch :/
Comment #10
catchI think we should be checking EntityTypeInterface::isTranslatable() here instead of the langcode key directly.
It's the same check in practice (unless we checked if bundles were translatable but that's not really reliable for views).
Comment #11
leolandotan commentedHi guys,
I added the recommended change from @catch regarding checking for EntityTypeInterface::isTranslatable(). I hope everything is in order.
Thank you!
Comment #12
amateescu commentedNice, thanks for the update :)
Comment #13
catchSorry that change got me thinking, also thanks @plach who checked this was sensible.
At the moment, the logic of the patch is that if the entity type supports translation, then it should join, but this is resulting in a join in at least two cases where it's not necessary:
1. The site only has one language configured.
2. The site has multiple languages configured, but the entity type we're working with has no bundles with translation enabled.
I think we should do all three checks here - the site is multilingual, the entity type is translatable, at least one bundle has translation enabled.
There's a third issue that plach pointed out, is that bundles where translation has been disabled may have old translations in the database. This may mean we can't rely on 'at least one bundle has translation enabled' but we could check that the site is multilingual.
Comment #14
amateescu commentedThat's not entirely accurate :) We need to perform the join every time to ensure that we select a possible workspace-specific revision, and this patch is only about adding an additional
langcodecondition to that join.That's a really nice point. Since we can't rely on any bundle being translatable or not, I only added the "site is multilingual" check.
Comment #15
catchOh good point extra condition not extra join.
Committed 88fede1 and pushed to 8.8.x, and cherry-picked to 8.7.x. Thanks!