Needs work
Project:
Drupal core
Version:
main
Component:
layout_builder.module
Priority:
Major
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
21 Feb 2018 at 07:00 UTC
Updated:
20 Apr 2026 at 21:36 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
tim.plunkettFieldBlock is actually fine here, it's that Layout Builder is passing it the wrong entity.
This is somewhat related to #2942907: Entity system does not provide an API for retrieving an entity variant that is safe for editing
Comment #5
tim.plunkettThanks d.o for installing in a subdir to catch my naïve implementation of getting the translated entity URL.
Also had to fix/expand the OverridesSectionStorageTest.
Comment #6
samuel.mortensonJust following this logic - if I create a translation of an overriden entity, then remove all sections on that translation and save, the default translation's sections will show up. I thought that if a translatable field didn't have a translated value, accessing it would get the default value. This just seems a bit manual to me, but I could be wrong.
In
getStorageId, IDs of translatable entities should now contain their langcode. Why does this method not respect that and check for a langcode when exploding the ID?Comment #7
tim.plunkettTagging as this is currently on our shortlist.
Comment #8
swentel commentedTested this patch on site we're working on and works fine. This is what we saw happening.
The site has 2 languages, where Dutch is the default.
It might be important to note that there were no fields rendered on the page, just views blocks and custom content (text) blocks.
Before the patch
The layout of the dutch node was overridden and had some custom blocks on them.
When we went to the english version, there was just a blank page.
When we edited and added a block, the Dutch version also was affected.
After the patch
When going to the english version, we saw the blocks that were configured on the Dutch version.
When clicking on layout, all the sections were empty and when adding a block, saving and viewing it in the frontend, we could see that one block. The Dutch version was also still rendered as configured before.
So the patch works fine, and I'm totally fine with the behavior at the moment which is:
So +1 from me.
Comment #9
swentel commentedThere's still one problem with translations and it seems to be a layout builder's problem in combination with entity references.
Setup:
Will dig a bit to see if I can quickly find this problem.
Comment #10
swentel commentedSo the problem is in layout_builder/EntityViewDisplay::buildMultiple().
It contains logic to determine the language the field should be rendered in, but with the current patch, the right entity is already known.
It's then up to the formatters to determine what needs to happen which can be tricky business, especially in case of entity references. However, EntityReferenceFormatterBase::getEntitiesToView() has logic to determine further what needs to happen with the referenced entity, so in the end, the actual fix, is deleting code in layout builder :)
I've attached the diff to see what needs to be removed. Translatable entity reference which are synced are fine now. Less complex fields, like say body, which are marked as translatable on the content type still work fine as well.
Could use confirmation from plach and/or berdir of course :)
- edit - ignore the patch, completely wrong hacking, my god
Comment #11
swentel commentedCrap, I did something completely wrong here, hacking in the wrong class, I guess it's too warm :( Ignore my comment in #10
However, the problem is still there, it's in the wrong language.
Comment #12
swentel commentedOther than that, while debugging, I noticed that (some) fields are being built twice. However, given my brainfart hacking in #10
I will re-confirm that before I open an issue for that (not sure if it's related with this patch or not)
Comment #13
swentel commentedOk, so, the problem with entity reference and language is related with #2955392: EntityViewBuilder::viewField() does not respect entity current language when used with an entity reference field. The patch in that issue solves it here, going to figure out if I can make something out of it.
Probably important: I'm not even using the current patch at all at the moment, all other fields, marked as translatable on the content type are rendered fine, but it's in the case of synced field on the content type with a translatable reference item where it goes wrong at the moment.
(using default layout, not tested layout per entity, iirc, that's what this patch fixes)
Comment #14
swentel commentedOk, attached diff which respects fields and translations now.
There's much code duplication as the singleFieldDisplay method is protected in the entityViewBuilder.
Just leaving here, I don't necessarily think this should be included, unless we add it temporarily and remove it when the core issue is fixed.
Comment #15
swentel commentedComment #16
swentel commentedSo in conclusion:
Next steps:
(glad I figured this out finally)
Comment #17
tim.plunkettBumping to major, but removing from our tag since it's not actively being worked on.
Comment #19
johnwebdev commentedComment #20
johnwebdev commentedComment #21
johnwebdev commented@swentel Great work! I've updated the issue summary to be scoped to focus on:
Feel free to open a follow-up issue for the FieldBlock issue.
Comment #22
tim.plunkettComment #23
ariane commentedIn drupal core 8.6.1 I am unable to apply patch in #5
Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2946333-layout_translation-5.patch
Comment #24
artem_antonov commented@ariane i just fixed a patch from #5 for 8.6.1 version in order to be applied with composer
Comment #25
johnwebdev commentedReroll of #5
Comment #26
johnwebdev commentedComment #27
andypostIS needs point how that gonna be solved
Comment #30
johnwebdev commentedBack to green!
Comment #31
johnwebdev commentedComment #32
johnwebdev commentedUpdated the issue summary. Might need a @todo on #2942907: Entity system does not provide an API for retrieving an entity variant that is safe for editing
Comment #34
tedbowI testing this patch with inline blocks and I ran into a problem
To see the error you have to have the changes in #2968110: Layout Builder's ConfigureBlockFormBase forms do not display validation errors on submit
You will still get the error without it just won't be displayed.
If you don't have #2968110: Layout Builder's ConfigureBlockFormBase forms do not display validation errors on submit the form just won't submit with no error.
This is because the Spanish version of the layout saves the same block_content entity. So it creates a newer revision.
When the english layout form tries save the previous entity it gets this error because there is a newer revision.
Possible solutions
If block_content entities are not translatable
When creating the translate layout field override duplicate the block so it is new entity.
This what we do if you are creating an override for the first time.
OR we could only duplicate the block the first time user tries to make a change.
But either way the spanish translation would never see newer changes made to the inline block in the english layout translation because we reference revisions.
If block_content entities are translatable
In this case instead of just creating a duplicate we could actually create a translation of the block.
Non-revisionable entities with Layouts
I haven't tested this but looking at
\Drupal\layout_builder\InlineBlockEntityOperations::handlePreSave()if entity with the layout is not revisionable if we don't duplicate that block we would always be saving the revision of the inline because we would not be creating a new revision.
So the changing the inline block in either layout would effect both layouts. So this favors just duplicating the inline blocks when making a translation.
Either way we need tests for the inline block functionality so tagging.
Comment #35
johnwebdev commentedHere is a updated patch with a failing test based on comment #34.
Comment #37
johnwebdev commentedLet's see what happens now.
Comment #38
nimoatwoodwayWorks with 8.6.2 too! Many thanks! Saved my day!
Comment #39
johnwebdev commentedSetting back to NW, still working on this
Comment #40
tim.plunkettSplit that clone portion into #3013197: Cloning an implementation of SectionListInterface does not deep clone the Section or SectionComponent objects
Comment #41
johnwebdev commentedComment #42
johnwebdev commentedThis patch includes patch from #3013197: Cloning an implementation of SectionListInterface does not deep clone the Section or SectionComponent objects. Added tests for translating a node, and then overriding it from default.
Also added a test for deleting a translation which currently fails. So i'm expecting this to go back to NW soon :)
Added #3013340: Add langcode column to inline_block_usage which most likely blocks this issue.
Comment #44
johnwebdev commentedOk, here are one patch with patches from related issues to make it pass, and a review patch. Now looking for reviews!
Comment #46
johnwebdev commentedComment #47
tedbowShouldn't all this logic be moved within the if statement where we check if
$sections?Also we need a comment to why we need to duplicate blocks on translations.
It seems weird that inline blocks would the default language when we know they are part of the layout translation. But also when we first duplicate them they obviously aren't the new language yet.
What if when they are edited if they are translatable and they aren't language of the current translation when set them to be?
Comment #48
plachHere's a plain reroll of #44 now that the blocker is in. #47 was not addressed.
Comment #49
julenmelgar commentedHi, in version 8.6.4 the patch stops working.
Comment #50
tedbow@julenmelgar thanks for reporting but patches are not expected to apply/work except against the git branch for Version on the issue. In this case that is 8.7.x.
Comment #51
tim.plunkettWas going to tag this as `Needs reroll` but it applies cleanly. But it no longer passes tests, so still NW
Comment #52
johnwebdev commented[#48] misses patch from #3013340: Add langcode column to inline_block_usage, but i'll let the issue remain in NW for now. will look in to this soon, but if someone is interested in continuing the patch feel free to do so
Comment #53
tedbowjust a reroll
Comment #55
tedbowtest fixes
Comment #56
tedbowComment #58
tedbowOk this is a first pass to produce a patch using the patch @plach produced in #2942907-35: Entity system does not provide an API for retrieving an entity variant that is safe for editing(say that 3 times fast 😜)
\Drupal\Tests\layout_builder\FunctionalJavascript\InlineBlockTranslationTestwill still fail. I started to address that but the logic for inline blocks still has the assumption of how overrides store their sections which needs to refactored. I am going to create an issue for that.Comment #60
johnwebdev commentedI know that you're addressing different issues currently, but I still want to adress your question in #47
I actually lifted this up previously in the proposed serialisation approach and the only benefit I can see is that it would allow us to have the layout not being translatable, but being able to translate the inline blocks. However, there is no UI for that (since we hide the inline blocks from the other UIs.). Maybe there could be a UI if there is a need for this.
We need to prevent this, and if we were to use translations, we'd need to make sure they don't set the language than the current language to a different language anyway.
There are obviously many more scenarios we need to take in to consideration if we were to go for this approach. What about non-translatable fields on the block?
Are there other benefits I'm overlooking?
Comment #61
tedbow@plach point out that I could use
\Drupal\Core\Plugin\Context\ContextRepositoryInterface::getAvailableContexts()here. So that removes the need for the language manager and finding the langcode all together.Comment #62
tedbowOk. this patch focuses on only getting
\Drupal\Tests\layout_builder\Functional\LayoutBuilderTranslationTestto pass. I have taken out logic that may have just been put into to deal with inline blocks logic. Those test will fail.It seems the only non-tests changes are to
\Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStoragewhich makes sense. This may be easier to review while work is done on #3026434: Ensure that Layout Builder Inline Blocks doesn't assume section storage internalsComment #65
tedbowok since we are getting the language from the context not the only reason we need it added to the storage id is so the tempstore will be vary by language.
There is not reason tempstore id has to exactly match the storage id but I don't think we can get the language inside
\Drupal\layout_builder\LayoutTempstoreRepository::set()because we only have aSectionStorageInterfaceinstance.Comment #66
tim.plunkettOpened #3026698: Allow section storage to provide a more granular ID for tempstore to address #65
Comment #67
tedbowOk here is patch with the changes to the API here: #2942907-40: Entity system does not provide an API for retrieving an entity variant that is safe for editing
I removed the test methods from
\Drupal\Tests\layout_builder\Kernel\OverridesSectionStorageTest:testGetSectionListFromIdTranslatableNoTranslationandtestGetSectionListFromIdTranslatablebecause
\Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage::getSectionListFromId()has no logic for translation anymore it just calls\Drupal\Core\Entity\EntityRepositoryInterface::getActive()We do have to test right now if it can handle when the langcode is in the storage id but that is it. So expanded the dataProvider for
testGetSectionListFromId()to cover this. This may change with #3026698: Allow section storage to provide a more granular ID for tempstore if the storage id is always the same but the tempstore id is different.The new API allows us to remove the thin helper method I had for
\Drupal\Core\Entity\EntityRepositoryInterface::getActive()to load the entity and get the contexts, since this is now handled by\Drupal\Core\Entity\EntityRepositoryInterface::getActive()🎉Comment #69
plachQuick code review:
This can go now :)
Comment #70
tedbowFixed #69
This is mega patch with #2942907: Entity system does not provide an API for retrieving an entity variant that is safe for editing & #3026434: Ensure that Layout Builder Inline Blocks doesn't assume section storage internals
\Drupal\Tests\layout_builder\FunctionalJavascript\InlineBlockTranslationTest::testDeletingTranslatedEntityWithInlineBlock()should fail. Because it is expects that the inline block would be deleted when you delete a translation.For that to work we would need #3013340: Add langcode column to inline_block_usage. But I think there problems with that approach. Namely before you make a translation you can actually switch the language of the entity with the layout. This would complicate the tracking.
One option would be to just not delete any inline blocks until the parent entity is deleted. This would you would have inline for translations that have not been delete but you would not be deleting in blocks for previous revisions that had a different language when you delete the translation that was afterwards added in that language. You can read more about the scenario on #3013340: Add langcode column to inline_block_usage
My idea here is that if there no sections on the translation we need to get the sections from untranslated entity.
This is true but if we actually return back the
$section_listitself then this will be used to update the sections when configuring the translated override. This results in the translated override actually being stored in the default language key.So the solution here was just to copy the sections into the translated section list if empty. This will work for render and for configuring the entity.
Comment #71
tedbowWhoops here are the patches
Comment #73
tim.plunkettThis should be done in #3026698: Allow section storage to provide a more granular ID for tempstore
Comment #74
ismail cherri commentedI tested the patch in #71 and it fixes the issue in Drupal 8.7.x-dev
Comment #75
tedbowComment #77
nikhileshpaul commentedJust to be clear, does this issue affect only versions 8.6.x+ or not. I was able to update the translated content in my Drupal installation 8.5.4, but not in 8.6.1
Comment #78
tedbow#2942907: Entity system does not provide an API for retrieving an entity variant that is safe for editing needs a reroll so not providing a patch now but I found a problem here.
If we add after this the check
The last assert here will fail. That is because the issue detail in this new issue #3033686: Saving Layout override will revert other field values to their values when the Layout was started.
Basically what happens in the test is:
translated_layout_urlis hit before we have a saved override for the untranslated entity.This wipes a layout but points a general problem that we save all the previous field values in the tempstore so this would happen with any field value which why I created the other issue to address this first.
Comment #79
tedbowComment #80
tedbowComment #81
tim.plunkettThe blocker is back in!
Comment #82
bendeguz.csirmaz commentedHere's a reroll of "2946333-75-do-not-test.patch".
I had to remove the OverridesSectionStorageTest modifications, because that class is completely different now.
Comment #83
bendeguz.csirmaz commentedHere's a combined patch of #82, #3026434: Ensure that Layout Builder Inline Blocks doesn't assume section storage internals #66 and #2942907: Entity system does not provide an API for retrieving an entity variant that is safe for editing #115.
Comment #84
johnwebdev commentedComment #85
tedbow@bendeguz.csirmaz thanks rerolling. Sorry this issue is a complicated mess right now.
reroll of https://www.drupal.org/files/issues/2019-02-11/2946333-75-do-not-test.patch
we don't actually need #3026434: Ensure that Layout Builder Inline Blocks doesn't assume section storage internals right now.
So just including #2942907-149: Entity system does not provide an API for retrieving an entity variant that is safe for editing
I am not sure the current approach is going to work.
I talked this over with @tim.plunkett and it might be better to have a new section storage
TranslationOverridesSectionStorage extends OverridesSectionStorageThen we can give it a weight so it has priority over OverridesSectionStorage
Comment #86
tim.plunkettI'm not even sure you want to extend it. Possibly, but I'd suggest trying without that first
Comment #88
tedbowupdated Proposed resolution with detail description
Comment #89
johnwebdev commentedSorry, I'm not up-to-date per se (but I read the updated issue), but why would we need a TranslationOverridesSectionStorage?
Comment #90
johnwebdev commented@tedbow Please adress my concerns in #60 about translating the inline blocks
Comment #91
tedbowI talked with both @johndevman and @plach today about this issue and specifically how inline block translation will work.
For this reason I think we should actually be duplicating the blocks when we are creating a translation of the entity with layout rather than creating translations of the blocks. The other reason this will be better is because once you translate an override it is has no connection to the untranslated override. You can add new blocks and reorder blocks. So there will not be a way logically through the UI to connect a block to its translation on a translated override. They could be in totally different parts of the layout or not exist at all.
layout_builder__layoutfield itself is translatable. It may not be translatable even when the bundle is translatable.I talked with @plach about this and he suggested that if the
layout_builder__layoutfield itself is NOT translatable then we should offer the ability to translate the individual inline blocks.While I agreed with this when we chatted I have since had second thoughts
There are 2 big problems with this:
J
layout_builder__layoutfield is not translatable doesn't mean that the field won't later be turned on for translationsIf we have different behavior for when
layout_builder__layoutfield is not translatable vs when it is translatable then we have to some sort of migration for when the field becomes translatable. Would we do that for all entities of the bundle or just as the new translated override layout gets created for an entity that didn't have 1? If don't do migration should we keep offering the ability translate the individual inline blocks if you haven't create an translated override yet?I think there are just 2 many possibilities and the migration could be very tricky and involve thousands of entities.
If
layout_builder__layoutfield is not translatable don't allow any translating of inline blocksIf
layout_builder__layoutfield is translatable duplicate the inline blocks when creating a layout translationComment #92
tedbowHere is an updated
this logic I just don't think is going to work.
I have changed the patch so that there will be separate section override section storage per entity translation.
Comment #93
tedbowwhoops here is the patch
Also #2942907: Entity system does not provide an API for retrieving an entity variant that is safe for editing was committed!!!!!!! So no combo patch!!
Comment #94
tim.plunkettIs this 1:1 built on top of #2942675: Layout builder should use the active variant of an entity to avoid orphaned revisions or just similar?
I think the proposed resolution is good.
Just some concerns about how self-contained this logic should or could be.
This seems like it should have a method somewhere. Could be a follow-up of course, might even be an "upstream" addition.
Looks like you could keep the
!$section_storage->isOverridden()in the original conditional?I have no idea how possible this might be, but could this be contained within
findByContext()somehow, somewhere within that call stack?While our current implementation does mean that overrides == content entities, I think these 3 might deserve their own interface.
Layout Library, for example, is a config entity that implements OverridesSectionStorageInterface.
Plus, adding a new interface is more BC friendly.
Whenever hardcoding
full, please include the @todo we have elsewhere.It's something like
// @todo Expand to work for all view modes in https://www.drupal.org/node/2907413.Also see the code in
OverridesSectionStorage::deriveContextsFromRoute()that ensures the view mode is the 100% correct oneComment #96
tedbowisApplicable()but setting the entity to the untranslated if the default is not override. But feels wrong to set something there isis*()method.I look at doing it in
setContext()but this is also called inload()which has other side-effectsI could put the logic directly in but doesn't seem much better.
also did this with tests
Comment #98
tedbowActually we don't need to be testing here if the entity itself is a new translation. It never will be using the layout builder as the entity has to already created.
We need to check if the layout translation is new. So for this translation were the section empty before.
I have fix for this. I thought I could use
$entity->originalbut this does not work.I had to do.
$unchanged_translation = $this->entityTypeManager->getStorage($entity->getEntityTypeId())->loadUnchanged($entity->id())->getTranslation($entity->language()->getId());So I am loading the unchanged and then getting the translation we are currently working with.
This gets the test methods in
InlineBlockTranslationTestto pass except fortestDeletingTranslatedEntityWithInlineBlock()which I don't expect to work yet.Comment #101
grahlHi there
I was evaluating Layout Builder as a Paragraphs alternative and found this issue when looking around for inline block translations. I'm concerned about the feedback in #91, specifically:
That approach is impractical for the vast majority of editors I've worked with. It would mean that after initial page creation, that adding a block to n languages would mean creating n blocks. Reordering a page would have to be done in each language separately. Furthermore, even if you use media entities, changing a reference to another media entity could mean editing n blocks again, even if the field itself is untranslated.
The proposed solution in #91 is a consistent solution to asynchronous translations but I believe the synced translations are the much more common scenario, and if I read the issue correctly, synced translations are not planned to be supported, right?
The solution which would make most sense to me would be to make layout overrides untranslatable (that can be set already but makes "Layout" disappear) and add a translation edit mask for inline blocks (in lieu of "customize" on the block).
Is there maybe a chance that this approach could be revisited or amended for this use-case?
Comment #102
tedbow@grahl you concerns are very similar to others I have heard from @Gábor Hojtsy, @plach, @lauriii and others.
I think agree need to switch to supporting synced translations.
Right now in 8.7.x we have minimal support for un-synced translations but this was unintended in consequence of #3004536: Move the Layout Builder UI into an entity form for better integration with other content authoring modules and core features.
I was assuming we had to support this because to take away this functionality would be BC break. But since #3004536 was not backported to 8.6.x this functionality has actually never been in core release! so are free to not support this anymore.
I am working on a more detailed plan. But right now the idea is to have the actually layout not be translatable but have 2 things be translatable
Comment #103
grahl@tedbow Thanks so much for the quick response, the approach sounds great!
Will keep an eye on this issue to see if I can assist with that feature in some way.
Comment #104
tedbowGot a help from @tim.plunkett about this actually might be implemented.
Ok here is a start to #102. The interdiff is bigger than the patch so I am not sure how useful that will be.
It doesn't handle inline blocks yet.
We also will need to be able translate the default(per bundle) layouts. Probably much of the same logic can be reused(provided we have same behavior of only allowing translating of block labels and inline blocks)
Because this method does not use the actual layout field translate value for storing translated sections(sections themselves aren't different) it leaves the possibility use field per language values later for actually creating totally independent layouts per language(truly different field values)
Comment #106
johnwebdev commentedEnded up being a small review for now, will make a more in-depth review as the patch is in a more clear state. Some questions and thoughts though:
Using 'not' operators make this really hard to interpret by looking at it.
Could we move the "$is_translation" - part to a method instead. This would make it easier to override for contrib. We don't really need to say "isTranslation", either it could be more generic, which would make sense for a contrib. like "Section lock".
It could be a "Read-only" state if we were to make this more generic.
It would be cleaner code to have separate methods for a read-only and default mode.
How would this work if the block plugin provides its own layout_builder_translation form and ignores labels?
Do we really use the language interface here? Not the content language? Might work differently in contexts though, I don't know for sure.
Some obvious things here with code standards, but I suppose you haven't gotten to that yet.
Maybe just Label? If you add the translate form block, it should be kinda implicit anyway.
Comment #107
plachI just had a first code review, I realize this is a wip so feel free to disregard all the nitpicks :)
No translation requirement here?
Typo, also I'm not sure what this comment is trying to tell me, but maybe that's ok :)
Unused
Missing PHP docs
Missing type hint
We normally use
langcodeto denote language codes, this should becurrent_langcode.Extra whitespace before =
Seems fair
Is this really the case with LB targeting stable?
I'm not sure what this comment is trying to tell me either :)
Not used
Why?
Comment #108
plachGood point, we should probably use content language here. However with the Context API it's a bit tricky, see
EntityRepository::getContentLanguageFromContexts().Comment #109
tedbowre test fails in #104
LayoutBuilderMultilingualTestfailed because now you cannot add new blocks in the layout translation. Changed this use a node in different language(not a translation). This still will fail if the fix if #3019333: If you translate the literal "inline blocks" to another language in the layout builder, it stops working. is commented out.\Drupal\Tests\layout_builder\Functional\LayoutSectionTest::testMultilingualLayoutSectionFormatterchange a node in another language.New Tests
Added basic tests for translating labels. Wanted to do this before address the reviews so I don't mess up existing behavior.
re #106
@johndevman thanks for the review.
$this->isDefaultTranslation() || $this->isOverridden()$sections_editabl. This allow removing most of the if statements and just using'#access' => $sections_editable.Since this is local var this won't really help contrib except if that wanted to undo the access restriction which is dangerous but anytime you undo access it is dangerous.
$sections_editableto consistent.So I will tackle this when I do the inline blocks logic. Because even if no label is displayed in the case of translatable inline blocks we still need to be able to translate the block.
adding todo for now.
Actually we have the entity that we are going to display so I think . we can just use the langcode from the entity itself. Because isn't the context on the request scope? We could be rendering an entity in a different language than the main page is, correct? So we want the langcod of the actual entity being rendered by the laytout builder. which might be a entity rendered in a view.
re #107
@plach thanks for review
Basically right now if you open up the translated layout and at the same time you(or someone else) opens up the untranslated layout and saves untranslate first with changes, I think saving translated will undo changes. Because of the tempstore. Need to confirm and prevent this.
Basically it is true until it is not 😜
Comment #110
tedbowNeed an else here with an exception for unexpected value.
All of this seems be unneeded. Tests pass without it.
Removing
Comment #112
tedbowfix #110 and code sniffer problems.
There is problem with field blocks and label translations. Pretty sure this because they are ContextAwarePluginInterface and other blocks aren't.
Need to fix and use them in tests.
Comment #113
johnwebdev commentedRe #109
2. We could use a "isEditable", method or something similar on the section storage as well. But I like this change I think, it's less duplicated code now :)
5. Well, it depends, the labels might not be used. For instance, in a project I build, we've removed them.
6. I agree, that looks good.
Comment #114
tedbowfixed the field blocks issue. It won't crash layout builder now but still the translated labels won't show up because of #3039185: Allow field blocks to display the configuration label when set in Layout Builder.
So added test coverage which I have commented out with todos.
Comment #115
tedbowWe don't actually need to check the defualt translation sections anymore because we are not using separate sections per translation. Removed this and removed it from the interface.
LayoutBuilderTranslatablePluginInterfacewithhasTranslatableConfiguration. This allows plugins to determine for themselves if they aren currently translatable. For inline blocks if the block type is translatable they are too.InlineBlockTranslationForm extends BlockPluginTranslationFormThis will simply create a translation if it doesn't exist or load the existing translation.InlineBlockTranslationFormas thelayout_builder_translationfor inline block plugin.Comment #116
johnwebdev commentedLooked through the interdiff, looks good to me!
$element['langcode']['#access'] = FALSE
Doing a manual review now.
Comment #117
johnwebdev commentedIf this condition is true because of the configuration, the inline block form must be hidden.
Tested on 8.7.x
Setup
Installed Language, Content Translation
Installed Layout Builder, Layout Discovery
Added Swedish language
Enabled Layout Builder and Overrides on Basic page
* Layout is not shown under Content language 👏
* All inline blocks was successfully deleted when I removed all nodes after the tests below, in preparation for next patch :)
#1
* Created a node (en)
* Added a 'Basic block' inline block with label and body
* Translated node
* Translate the inline block
* Sets the label and body differently
* The label is translated properly
* The body shows the Swedish translation on the English node. If I update the English inline block again it is shown on the Swedish node.
So, it looks like I didn't enable translation for the block type. When I do that, the translations works as expected.
#2
Now I set the 'Body' field to be untranslated on the Block type.
* Created a node (en)
* Added a 'Basic block' inline block with label and body
* Translated node
* Tries to change the inline block body of the translated node, nothing happens (as in it's not translated, when I update the translation)
* Tries to change the inline block body of the original node, nothing happens. (as in it's not translated, when I update the translation)
#2 Untranslated fields should not be shown on the translate inline block form?
Comment #118
tedbow@johndevman thanks for the manual review.
Ok so the ability to translate the block should NOT have been there if the block was not translatable. You should have only be able to translate the label(if shown) as with other blocks.
I forgot that the translation form was being shown even if the block is not translatable when the label needs to be translated. But in the form logic I didn't account for this.
fixed so that the block entity form is only show if the block entity is translatable.
there is setting on the translation page "Hide non translatable fields on translation forms" that we should probably respect. In less we think inline blocks are such a special case that the non translatable fields should only be shown on the default translation layout.
That would be inline with other settings in the other blocks. They affect both untranslated and translated layout but we only show them on untranslated.
Anyways if we did want to respect that setting I am not sure how content_translation is enforcing this now. I looked for the setting
untranslatable_fields_hidebut I don't see affecting the forms fields.\Drupal\content_translation\Controller\ContentTranslationController::add()andedit()to see if we need to implement any of the special logic it does to create the translation form. We might need to copy the logic now and do a follow to refactor that controller so we can just ask content_translation for the form. Of course we may not only all of the behaviors.This could handle the
untranslatable_fields_hidesetting for us. not sureMaybe @plach would know more about this?
Comment #119
johnwebdev commented#118.3 I'm not entirely sure on that setting, but I think it's more about solving data losses on pending vs. default revisions when using Content Moderation. Do we intend to support Content Moderation on Inline blocks? Or should we ignore it? If we should use that to hide neutral fields on the translations form I don't know.
Also, just to clarify: Currently you cannot change a language neutral field on the translation form.
Comment #120
tedbowI would say no. The entities with layouts can use content_moderation.
I suppose you could still enable content_moderation on the block types. So I don't know if we just don't support any block types that have content_moderation enabled or only support them if you can always save to the published state. And if a user cannot then they can't add/edit inline blocks.
InlineBlockTranslationFormto extendContentEntityForm. This will make it easier to integrate with content_moderation. We will then have to implement PluginFormInterface. and maybe move some logic inBlockPluginTranslationFormto a trait so it can reused inInlineBlockTranslationFormstill enve that we can't extendBlockPluginTranslationFormany more.Comment #122
tedbowtalked to @tim.plunkett and @plach
The combo of layout_builder + content_moderation + content_translation is going to make it super difficult to store a layout that will be the same across all languages(when each could have a forward revision) and the translate labels in 1 field.
I am working storing the translated labels(and maybe future other plugin settings) in another field that will be translatable.
This is NOT different layouts per language. Just different settings per component per language. With core hardcoding the restriction for just 'labels' for now.
Comment #123
tedbowHere is the first try at #122
Sorry I don't have to explain more about the approach. I will in 5 or so hours
Comment #125
tedbowThis adds translations of inline blocks in layout translations with test coverage.
Next working on translations of layout defaults, DefaultsSectionStorage.
Comment #126
tedbowThe interdiff was incorrect and used the wrong extension
Comment #128
plachCode review for #123:
Typo
$languagecan't be null according to the interfaceShould we mark this as internal or are we planning to expose it to HTTP API clients?
We could return early here if the site is not multilingual.
Does this return the correct entity translation?
Let's inject the language manager :)
Wrong indentation
Missing { }
Why do we need a new type? Isn't a map item enough?
Unintended change?
Missing @param description.
Code review for #125:
Why are we doing this? Revision negotiation should not be performed when the ID of the revision we need to load is known in advance. Additionally we are instantiating the desired translation afterwards, so I don't see the point of these calls.
Comment #129
tedbow@plach thanks for the review. Just want to address to 2 points as I am working on the defaults translations.
#123
But we will have to do the same thing we did with our existing field here #3028301: Do not expose to Layout Builder's sections either in defaults or overrides to REST and other external APIs
#125
We store the revision because we want to render the exact revision of block with the exact revision of entity with the layout.
but if we don't call
$this->entityRepository->getActive()and the revision id is not the latest, because a new revision was made when creating a translation of the inline block in the translation layout we will get an errorThis why I expanded the test
\Drupal\Tests\layout_builder\FunctionalJavascript\InlineBlockTranslationTest::testInlineBlockContentTranslation()This would fail if we didn't have the
getActive()call in\Drupal\layout_builder\Plugin\Block\InlineBlock::getEntity()because we have just update the translations layouts inline block.This would also fail if we didn't have
getActive()call in\Drupal\layout_builder\Form\InlineBlockTranslationForm::getEntity()Comment #130
xjmThanks @plach and @tedbow.
@webchick, @Gábor Hojtsy, @effulgentsia, and I discussed this issue today. We should take the approach here that we did for Layout Builder's REST support as well as JSON:API's translation support: Start by disabling translation entirely, so that we don't get into a situation where we might have data integrity problems or lost work due to incomplete translation support. That's the minimum scope that needs to be a stable blocker, because it affects site data and sitebuilding decisions that are difficult to change after the fact. Tagging "Needs followup" to create a new issue for that first step, and postponing on it.
Then, we'll add Layout Builder translation support back once we're ready to ship translation of labels in defaults, labels in overrides, and inline blocks as a single integrated feature with integrated UX. @webchick and @Gábor Hojtsy confirmed that from a product perspective this can be treated as a missing key feature, which does not need to block marking Layout Builder itself stable. (It would be a blocker for enabling Layout Builder in Standard.)
Comment #131
tedbowper #130 created #3041659: Remove the layout tab from translations because Layout Builder does not support translations yet
Comment #132
johnwebdev commentedThis is no longer postponed(?) and I also think this deserves a issue summary update, because the goals and approaches of the issue has changed a lot.
Comment #133
tedbowComment #134
tedbowComment #135
tedbowCopying over @berdir's comment from #3044386-7: [META] Make Layout Builder layouts translatable because it deals with overrides so is more relevant here.
Comment #136
tedbowHere is a re-roll of #125. There was a lot changes since then so I still need to double check but wanted to get the work started again here and see what tests fail.
Still needs work. Translations of labels is working but not for inline blocks.
Removing "Needs follow-up" as now this is a child issue of #3044386: [META] Make Layout Builder layouts translatable which has other related issues
Comment #138
tedbowCleaning up the last patch
Comment #140
tedbowThis trait was no longer used.
need to check here for
$block->isNew()because$this->isNewactually determines if form is adding a new block. If the block has been added and then you edit the block before saving the layout the block will still be new and there will be no active.It might be related to
\Drupal\Core\Entity\EntityBase::getCacheTagsToInvalidate()Not factoring in language so since the test already calls
access()the result will be cached.Comment #142
tedbowHad to look at
\Drupal\Tests\content_translation\Kernel\ContentTranslationEntityBundleInfoTest::testFieldSynchronizationWithDisabledBundle()to determine how to get a kernel test to work with translations. The problem before was$entity->isTranslatable()was always returning FALSE which affected\Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage::isTranslatable().Comment #143
berdirconfigurable_language is a config entity, that's not something you need to install.
Comment #145
tedbow@Berdir thanks for pointing this out. I copied this from
\Drupal\KernelTests\Core\Entity\EntityNonRevisionableTranslatableFieldTest.I couldn't find an existing issue for this so I created #3052430: Remove calls to installEntitySchema for config entity types in Kernel tests. It seems like this is done many times for config entities.
Comment #146
tedbow#143 fixed.
finally getting back to #128. @plach thanks for the review
I will ask @tim.plunkett why we didn't use
setInternal()on the field type definition.\Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay::addTranslationFieldI run into #2743175: SqlContentEntityStorageSchema::getDedicatedTableSchema assumes that a fields property definitions matches the columns. I thought I was using the Map field incorrectly but I think it is bug. will look into that issue. If we could use map that remove a couple of classes.
Looking at the failure in
InlineBlockTranslationTest. I added the new permission "create and edit custom blocks" to this test which should get it further but it still fails.Comment #148
tim.plunkett#2871591: Allow ComplexData in TypedData to specify computed properties that should be exposed in normalization and other contexts added setInternal and that landed in core after the LayoutSectionItem had been written.
Comment #149
tedbowThis patch
BlockContentInlineBlockTranslateForm extends BlockContentForm.I did this because to work with content_translation will really need to have a form that implements
ContentEntityFormInterface. This is because\content_translation_form_alterchecks for this. It will trigger\Drupal\content_translation\ContentTranslationHandler::entityFormAlter()which also probably assumes a form structure. So this would make it very difficult to use a plugin form.This seems to work well.
Comment #150
tedbowAdded ModeratedTranslationTest which tests the interaction between layout_builder, content_moderation, and content_translation.
Comment #151
tedbow..... and the patch
Comment #152
tedbowRemoving this comment because plugins can determine what can be configured in translations by providing their own 'layout_builder_translation' form.
Not used anymore
Thought of replacing this with just checking if configuration has values in translatable(according to schema) but here for example the label value only needs to be translated if it is displayed.
Also inline blocks only need to be translated if the blocks support translation
So I think we still need
\Drupal\layout_builder\LayoutBuilderTranslatablePluginInterface::hasTranslatableConfiguration()Removing this from the interface for now because it is never called.
Also should check here if
$definition['class']implementsConfigurableInterface. Then we can remvoe this check inBlockPluginTranslationForm.'
@internalto new classes that needed itComment #153
tedbowAdded this message
I think this predates the translation settings being in a different field so now we can't overwrite the layout settings.
refactored this because what is changing is the contextual group so not setting
$build[$region][$uuid]['#contextual_links']in multiple places just settings$contextual_groupRemove the need for this block by using an existing test block from block_test module. I needed 2 blocks and I was using "Powered by" and Search. But search was running into #3045171: Form blocks rendered inside layout builder break save
Comment #154
tedbowStarted on #3044993: Allow synced Layout default Translations: translating labels and inline blocks which led to a couple changes here
So the langcode need to be added this path so it could be extracted in
\Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage::deriveContextsFromRoute()in #3044993: Allow synced Layout default Translations: translating labels and inline blocks(not used in this issueThis was relying on the translation language being the same as the content language. That will not be true for config_translation.
Added
\Drupal\layout_builder\TranslatableSectionStorageInterface::getTranslationLanguage()so the translation can be determined by the storage itselfComment #155
tedbowMore changes from #3044993: Allow synced Layout default Translations: translating labels and inline blocks
This will not work for defaults.
It is only working here because the entity context is from the storage and the entity itself store the translations in another field. So
$section_storage = $this->getSectionStorageForEntity($entity);will return not the same as in tempstore but made from the same entity which stores the translation data.so here we need to change this to actually use the section storage when
$entity->inPreview(). Then we can be sure the translation data will be available regards of how it is stored internally in the storage.Comment #156
tim.plunkettOverall I think the approach is sound. This is tricky stuff!
Any particular reason the _permission is still used? That was removed from all other routes when we improved _layout_builder_access
Nit: not needed, AccessResult is always refinable
Nit: missing blank line
In theory we have to treat this as an optional param for BC
That's not something you see every day!
This gets complicated very quickly. Should it be split out to a new method?
Nit: missing one-line doc
Need to be careful here, reminds me of #3018782: Remove extraneous context mapping of layout_builder.entity
Reminds me of
\Drupal\layout_builder\Form\ConfigureBlockFormBase::getCurrentComponent()Maybe that should be a trait...
Why these 3? Are there others that might conditionally appear?
That seems odd
This method is kinda dense. Some newlines and/or inline docs would be nice
Nit: double space after the ||
Do we know we need this or is it just copy/paste
Do we want to go with 'big' to preemptively sidestep any issues? See #3030154: layout_builder__layout_section column hitting database limit
Nit: no else needed after a return
Comment #157
tedbowcreateContextualLinkElement(). As refactor this check$section_storage instanceof TranslatableSectionStorageInterface && !$section_storage->isDefaultTranslation()which I used in this class 2x and multiple other classes into\Drupal\layout_builder\LayoutEntityHelperTrait::isTranslation()ConfigureBlockFormBase::getCurrentComponent()is public and I don't think we need it public here\Drupal\layout_builder\Form\TranslateBlockForm::submitForm(). Added a commentComment #158
phenaproximaPartial review; I'm nearly a third of the way through.
I discussed this with @tedbow, but I'm not entirely convinced that adding an external isTranslation() helper method is the best approach.
It seems to me that it should be up to the section storage to determine if it is a
translation. To wit, maybe it would be preferable to add a new method to SectionStorageInterface, called isTranslation(), which would do the determining? I think that might be less new API surface than introducing a whole new interface, plus an opinionated static method on a trait.
If I understand the BC policy correctly, this change would fall under "Interfaces within non-experimental, non-test modules not tagged with either @api or @internal", which means we can add such a method with a default implementation in SectionStorageBase.
This seems a little harsh. Why not simply deny access and give this reason?
Nitpick, but would it make more sense for buildAddSectionLink() to do the isTranslation() check, and return an empty array if so?
This, on the other hand, seems like a good candidate for inclusion as a helper method in a trait. :)
Everything inside this if statement is coupled to the plugin implementation, so why not just check if $plugin instanceof InlineBlock?
I'm not sure about this label...it seems a bit limited considering the other stuff that can be (or may be in the future) considered part of a "layout translation".
This seems like it should be a || condition, not &&.
Should we also check if $contexts['layout_builder.entity']->hasContextValue()?
So, seeing as how section storage translations will always have the same sections, with the same layouts, containing the same components, I wonder if we shouldn't change the API design somewhat so that it reads more like an entity:
$section_storage->getTranslation($langcode)->getComponent($uuid)->getConfiguration(). The storage would return the translated component configuration if it existed, and the original language configuration if it didn't. IMHO, this is better encapsulation because it relieves the calling code of the responsibility of knowing if a translation exists: "just give me whatever you have in this language, if you have anything." The approach of this patch is to treat translation data as an "overlay" over the original language, so to me, it makes sense for the section storage (and calling code) to transparently fall back to the original language when there is no translation data.Just my $0.02.
Can't this just be @inheritdoc?
Comment #159
phenaproximaReviewed one more class...
I know this is not a particularly helpful complaint, but this method generally seems to be a bit scattered in terms of how many code paths it contains. It's not clear to me when it loads a translation, when it tries to create one, and when there is an error condition. I think we could really use some comments to explain the assumptions and code flow of the method, and possibly break up the code into protected helper methods.
Do we need to call getTranslation() on the unserialized block?
If the entity does not have the desired translation, it seems like we might want to throw an exception or something...? I know the code will fall through to the \LogicException at the end of the method, but the message that one carries might not be too useful under the circumstances...
This code appears to be duplicated above for $translated_configuration. Can it be turned into a helper method?
It's interesting that this method always sets block_serialized in the translated configuration. Why is that?
If these fields cannot be changed, we should completely unset them, so they're not part of the form structure at all, rather than set #access to FALSE (which, I think, just prevents them from being rendered).
Comment #160
tedbow@phenaproxima thanks for the review!
I have looked it over but haven't had time to respond yet.
For now I want to catch a major problem with the patch. It does not add the new field to bundles that already have the layout builder enabled for overrides. This patch addresses that.
It also updates
\Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage::handleTranslationAccess()to not allow access if the Layout field itself is translatable. This whole workflow really depends on the layout not being translatable.A site could have the field translatable because of custom code or if they are using Layout Builder Asymmetric Translation. That module already has to override
handleTranslationAccess()so it should be fine as far as access(they probably will need other updates after this patch is committed)Comment #161
sam152 commentedI believe the the test run here proves that this breaks editing blocks where the latest host-revision references a non-latest block revision.
That is, this prevents you from editing the correct block revision unless both the host and block revisions are linear, which isn't the case when you revert a host revision.
Comment #163
tedbowre #161 @Sam152 thanks I will look into this.
@phenaproxima sorry again I haven't addressed your review
I talked to @godotislate about this. He wondered if we could just us Config Translation edit for blocks because he is looking to use translation and he has a number of block plugins he is using with Layout Builder. The plugins have schema defined that is translatable.
Using these blocks outside of Layout Builder config_translation would just create the form based on which parts of the schema were translatable. For layout builder with the current patch a form class would have to be set as the
layout_builder_translationform handler in the plugin translation.We are setting a default 1 here:
Of course this would be a pain for everyone that have blocks that just work with Config Translation but for layout builder new form classes would have to be created.
So it would make sense to use config_translation for this.
Of course there are 2 big problems with this
But I think it would be big win if the translation of block in layout builder and block via the block module were translated in the same manner to the end user and the developer.
So this patch does:
layout_builder_translationplugin form handler.LayoutBuilderPluginTranslationFormInterface, 🎉for less API surface\Drupal\config_translation\FormElement\ElementInterface::getTranslationBuild\Drupal\config_translation\FormElement\ElementInterface::getTranslationBuildand related logic out of config_translation module because this really deals with TypedData translation not just config entities.)LayoutBuilderTranslatablePluginInterface🎉 which had 1 methodhasTranslatableConfiguration()which main purpose was to not show the "Translate Block" context link if the label wasn't actively being displayed to the user. config_translation doesn't worry about this and shows "Translate block" contextual link even if the block isn't showing the translated label to the user. This has the benefit of not having to get the translator if the block label is shown later. I think it is good to follow the config_translation pattern here and if it needs to change to change it in both modules.SectionComponent::hasTranslatableConfiguration()Comment #164
tedbow\Drupal\layout_builder\Element\LayoutBuilder::createContextualLinkElement()because this will always return a linkComment #165
mathg16 commentedThere is an issue with the latest patch. If one of the field of the inline block is a Paragraph reference, it loses it's reference to it and displays a permission error about not being allowed to view, edit or remove that paragraph, even in the original language.
Comment #166
sam152 commented@mathg16 I believe that is an issue in HEAD right now, see: #3047022: Layout builder fails to assign inline block access dependencies for the overrides section storage on entities with pending revisions.
Comment #167
yogeshmpawarComment #168
yogeshmpawarResolved the coding standard issue by removing the unused use statement & added an interdiff as well.
Comment #169
sam152 commentedUnfortunately, I think this should be NW until #161 is addressed. My preference would be to resolve all of the issues with reverted revisions before committing this, so the test coverage that proves the need for changes here is already in HEAD. I think that sequencing also works given translations are a new feature and reverts are currently possible and broken from the existing UI.
Comment #170
godotislateWe noticed that when translating an inline block, if we set the block title/label to be the same as the description for another block_content entity, saving the block will fail the UniqueField constraint on the block_content info field. This is occurring because the
BlockContentInlineBlockTranslateFormis saving the block_content entity directly, and runs validation on the entity in form validation.This validation isn't occurring on the default translation of the inline block, because while the entity is validated via
\Drupal\layout_builder\Plugin\Block\InlineBlock::blockValidate(), the violation is suppressed because access to the info field is set to FALSE in\Drupal\layout_builder\Plugin\Block\InlineBlock::processBlockFrom().It's probably ideal for the block_content entity to always be validated, but I think it'd also be best for the UniqueField constraint on the info field to be ignored for block_content entities that aren't reusable. (See #3054197: Cannot add a custom block with a block description already used by a non-reusable block).
Comment #171
godotislateThe inline block form is always loading the active block_content entity from the entity repository as long as it is not a new inline block or block_content. This is causing an issue in the following situation:
1) Create and save a node of a content type that allows layout builder overrides
2) Edit the layout to create the override, and add an inline block to any section.
3) Add block field data as desired and save the layout.
4) Go back to edit the layout.
5) Click to configure the existing inline block. Change field data to different values and update the block. Do not save the layout.
6) Click to configure the block again and notice that the block fields have stale data.
Patch and interdiff to #168 attached. Basically adds to the conditional to make sure that the serialized block_content isn't available.
Comment #172
godotislateI think I discovered an issue with inline blocks not displaying in the correct language when search_api batch indexes rendered nodes, such as when running cron via drush.)
Drupal\layout_builder\Plugin\Block\InlineBlock::build()does not pass a language code to the entity view builder `view()` method, so as a result, the language the inline block'sblock_contententity is rendered in is the current negotiated content language. For inline blocks in Layout Builder on a non-default language translation of a node, the language can be incorrect, causing the inline block content to be rendered in the incorrect language, so the node is indexed with the inline block's content in the wrong language.Workaround for now is to add an event subscriber to
Drupal\layout_builder\LayoutBuilderEvents::SECTION_COMPONENT_BUILD_RENDER_ARRAYthat runs after the component render array is built, and then rebuilds the block content based on the the language of the section storage.Comment #173
nghai commentedhello @tedbow
thanks for the patch! It really wonders.
I have one scenario where if we add the paragraph (entity reference revisions) field to a custom block type. Then the block is rendering without paragraph display when translations is added for the same.
Steps:
- create a custom block type with any paragraph (entity reference revisions) field
- add an inline block of above created custom block in a translatable node
- go to the translatable interface of that node layout and provide the translation of the same block
- result, block displays in frontend after saving the layout but without paragraph rendering fields
On checking, it is due to empty
$entity->getAccessDependency();response in the /core/modules/block_content/src/BlockContentAccessControlHandler.phplooks like some translatable management is required there as well to provide correctly the
SetInlineBlockDependency::getInlineBlockDependencyRelated issue: https://www.drupal.org/project/drupal/issues/3047022
Comment #174
godotislateWe've observed some undesirable behavior with content moderation involved:
Steps:
This isn't ideal if new versions of both languages should go through moderation at the same time (or at least without one language being published first).
Related issue: #3007233: Draft translations should be based on the latest revision of the source language, not the published version
Comment #175
nghai commentedwith respect to comment #173 - The missing inline block content with paragraphs
now it is determined that in
Drupal\layout_builder\EventSubscriber\SetInlineBlockDependencythe function
getInlineBlockDependencychecks if the block's latest revision id is same as the revision id stored withinsection component plugin configurations because it is mentioned that \Drupal\Core\Access\AccessibleInterface::access() will only check access on the latest revision
But this scenario is not applicable with Translation implementations of Inline blocks, as different block_revision_id stored for each language inside the node__layout_builder__translation. At the time,
1) below functions take the latest revision id from block_content table which could store the revision id of the added translation as well whereas the function
getInlineBlockRevisionIdsInSectionsonly retrieves the revision id from node__layout_builder__layout table (source lang field value)2) though we can use getTranslatedComponentConfiguration as well inside the function getInlineBlockRevisionIdsInSections like
but it will also retrieve the revision id from current language specific component configuration, not all the revision id associated to that entity / section in all languages. Hence, returns again false on not matching revision ids.
In this situation, some different logic is required to check the access for inlineblocks or we add a function that returns the revisions ids in all languages for an inline block
Comment #177
xjmDiscussed with @Sam152 -- it may make sense to postpone this issue on #3053887: Add test coverage and document why inline blocks require a new revision to be created when modified, regardless of whether a new revision of the parent has been created?
Comment #178
oleksiyReroll
Comment #179
oleksiyComment #180
oleksiyComment #183
aleevasAdded fix for latest patches.
Comment #185
ashwinshThe inline-block form is always loading the active block_content while editing.
Steps to reproduce:
Not sure but the issue seems to be in this code:
Comment #186
tim.plunkettNW for #185
Comment #187
sanjayk commentedComment #188
sanjayk commented@tim.plunkett I have checked #185 comment with and without layout builder. Issue is in revision not in layout builder. Same thing happening without layout builder. You can now move in RTBC.
Comment #189
tedbow@sanjayk thanks for checking #185
This needs to be rerolled against 9.1.x.
I would have read back on this comments here but doing a quick search I don't thin anyone has said it is ready for RTBC. It also still has "Needs tests" tag so at least we have to resolve that.
Comment #190
sanjayk commentedComment #191
sanjayk commentedI have rerolled the patch for d9
Comment #192
sanjayk commentedFixed the issues in patch. Test cases getting failed. If anybody interested work on it.
Comment #193
tim.plunkett@sanjayk Please upload an interdiff of your changes
Comment #194
maacl commentedThe Bug report of #185 comes from #3067646: Inline block loading active block_content revision even if serialized block exists of the "layout_builder_st" Module. There are tests, but the issue may not be resolved yet.
Comment #195
maacl commentedI worked on the reroroll and fixed some oversights I found.
Two questions from my side:
MakeLayoutUntranslatableUpdatePathTestBase.phpunintentional in https://git.drupalcode.org/project/drupal/-/commit/e1a041c4932d148e7116e...? I re-added the file and the changes to the file from #183.@todofrom the constructor incore/modules/layout_builder/src/InlineBlockEntityOperations.php? The parameters do not appear to be optional any more.I tried to add a Interdiff to the rerolls as per https://www.drupal.org/documentation/git/interdiff#reroll.
Comment #197
maacl commentedFixing the obvious fails and coding standard errors. I expect one test still to fail.
Comment #198
maacl commentedI re-added the
@todoI mentioned in #195.2, figured it is for BC. Please review if the changes are correct now.Still NW for the failing test.
Comment #199
maacl commentedThis should fix the failing test.
Comment #201
KuroiRoy commentedWe're trying out patch #183 and it mostly does what we want. The user is able to set a title for a block through the layout builder and then they could translate the title while translating the node. But somehow, for us, the user profile language influences the ability to translate a block in the layout builder.
Step to reproduce:
1. Create an English block.
2. Translate the block to Dutch.
3. Create an English page.
4. Add the block to the page with the layout builder and give it a title. (The block's content is now translated automatically)
5. Translate the page to Dutch.
6. Now, depending on user language settings, there will be an edit button on the block in layout builder that allows translation of the title.
Now this feels pretty weird and it may depend on the language detection settings of the website. If anyone needs further information please let me know
Comment #202
maacl commentedFound the error I did while rerolling, tests should be green now.
Comment #204
maacl commentedThis looks like a random fail, re-test is green.
Comment #205
Jorge Navarro commentedPatch #202 worked as expected in Drupal 9.0.3, without layout_builder_at nor layout_builder_st.
Comment #206
xmacinfoComing to this issue from #3044386: [META] Make Layout Builder layouts translatable.
Can we expect a reroll of this patch for Drupal 8.9?
Comment #207
tedbow@xmacinfo sorry but I don't think this feature will not be added to 8.9.x because it is too big of a change and there will not be a 8.10 release. New features will be on 9.x.
If you only need this for overrides check out Layout Builder Symmetric Translations I created that module from this patch. It is probably the only way to get this functionality for 8.9.x.
Currently though that module does handle defaults which is covered in this issue #3044993: Allow synced Layout default Translations: translating labels and inline blocks
Comment #208
xmacinfo@tedbow: Thanks you very much. I will try and use your module as long as we are stucked in Drupal 8.9.x, hoping it solves my use case.
Comment #209
tinytina commentedPatch #202 worked for me on Drupal 9.0.2 (fresh installation with basic/minimal configuration in terms of content_translation and layout_builder)
However, when i try to apply it on a system with existing content (including translations and layouts) there is a problem.
The original content works fine (i can view, edit, layout, translate as expected). When i try viewing the translated version i get this exception:
Seems like a new 'layout_builder__translation'-field is added by this patch which is now missing from existing content.
Does anyone have an idea on how to fix this?
Comment #210
tedbow@tinytina sorry I don't a solution. I think this should work but we don't have tests for it. Thanks for testing it out though. This points out we need more tests.
Comment #211
p-neyens commented@tinytina You need to run updb to trigger the layout_builder_post_update_add_translation_field.
Comment #213
lawxen commented#202 can't be applied to newest 9.1.x
Comment #214
ravi.shankar commentedComment #215
ravi.shankar commentedAdded reroll of patch #202 on Drupal-9.2.x
Comment #216
lawxen commented@ravi.shankar Thanks for reroll the patch,
The patch in #215 has the same problem of layout_builder_st:
Nontranslatable custom block fields are not synchronized between translations
Comment #217
lawxen commentedComment #218
heddnHopefully this fixes some of the outstanding BC test failures.
Comment #219
heddnThe errors in #209 indicate not running db updates. I didn't review the test coverage here, but if that is the only reason we added the needs tests flag, we could remove it. We would still need update path tests though, so :shrug:
Comment #221
heddnComment #222
heddnLayoutBuilderWidgetthrow exceptions when it is enabled in the form mode on nodes. This happens when editing a node or adding a translation.Comment #223
heddnFixes a small error in some cases where section storage cannot be loaded.
Comment #224
nwom commentedHere is an updated patch that includes the fix for Page Manager (#3119208: More defensive handling of empty $contexts['layout_builder.entity'] and broken blocks)
Comment #225
alexpottComment #226
nwom commentedHow would someone transition from Layout Builder Symmetric Translations to the patch within this issue on an existing site without having to delete content, fields, etc?
Thanks in advance! I'm sure this is also important for the future for others using the module.
Comment #227
jhedstromAdding a re-roll for 9.2.x.
When testing this, I'm running into what may be #3054197: Cannot add a custom block with a block description already used by a non-reusable block, wherein a translated block that doesn't update the block description hits this error:
Comment #228
jhedstromMaking this change in
BlockContentInlineBlockTranslateForm::form()seems to resolve the issue, but there is currently an explicit test for this element on the form as part of this patch, so I didn't update the patch yet as it's unclear if this is the proper fix.
Note that
InlineBlock::processBlockFormsets access to false for the info part, but the label is later saved into the block inInlineBlock::blockSubmit.Comment #229
arun ak commentedEven after applying patch from #224, I could not see the 'Translate block' link in the contextual filters of my block in the layout builder.
Comment #230
cgoffin commentedI noticed an error rendering the translated block when another formatter then the default is chosen. This is caused by the config merge of the config from the translated block (to get the translated title, ...) and the config of the original block. I added a patch that changes the merge to a deep merge. I will add this to the patch of #224 because this one is working for me.
Comment #231
cgoffin commentedHere also the deep merge added to #227. This one I haven't tested.
Comment #232
cgoffin commentedIgnore the patches of #230 and #231. Something went wrong generating the patches. Here the updated patch started from #224.
Comment #233
cgoffin commentedAnd the update for #227.
Comment #234
cgoffin commentedAgain something went wrong generating the patch. Here the adjusted version started from #224.
Comment #235
cgoffin commentedAnd the same change against the #227 patch.
Comment #237
dinarcon commentedReroll of #235 against 9.3.x
Comment #238
mauhg commentedReroll of #227 against 9.2.x
Comment #239
vflirt commentedI tested patch #183 on Drupal 8.9.14 and it works with Bartik theme however it does not work with other core themes. The issue is caused by seven and claro preprocess block:
as you can see they are removing all contextual links of 'layout_builder_block' key is not present which is the case when translating blocks.
Comment #240
vflirt commentedAdding patch and interdiff for the theme issue.
Comment #241
hswong3i commentedRe-roll #232 for 9.1.x.
Comment #242
tinytina commentedI was testing some of the patches:
With Drupal 9.1.11 and #241 i get the following error:
Fatal error: Class Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage contains 6 abstract methods and must therefore be declared abstract or implement the remaining methods (Drupal\layout_builder\TranslatableSectionStorageInterface::isDefaultTranslation, Drupal\layout_builder\TranslatableSectionStorageInterface::setTranslatedComponentConfiguration, Drupal\layout_builder\TranslatableSectionStorageInterface::getTranslatedComponentConfiguration, ...) in drupal\core\modules\layout_builder\src\Plugin\SectionStorage\OverridesSectionStorage.php on line 50With Drupal 9.2.3 and #238 translating inline blocks seems to work.
Comment #243
nginex commentedRe-roll #232 for 9.1.x.
#242 is taken into account.
Comment #245
nginex commentedI made a mistake in tests of re-rolling #232 for 9.1.x.
Here is new updated patch
Comment #246
nginex commentedComment #247
j-leeI'm a little bit confused about the progress here. It seems that the last real progress was at #224 for 9.2 roundabout a year ago.
Then there are a lot of re-rolls and new patches against different versions from 9.1 to 9.3 from different other patches:
#224 -> #232 -> #245 -> ...
#224 -> #234 -> ...
#224 -> #227 -> #235 -> ...
So, what is the current status?
Are the remaining tasks done?
From which patch should the work for 9.3 continue?
Comment #248
j-leeAfter some research, it seems that #238 is a good starting point.
I also fixed the problems with the spellcheck issues.
Comment #249
j-leeoops ... fixed patches
Comment #250
j-leeStrange ... after applying patch #238, I've got an .php.orig file created by git ...
I think, a new reroll for 9.2+ is needed.
Comment #251
j-leeReroll from #224 for 9.3 with the code styling fixes
Comment #252
j-leeAnd the reroll from #224 for 9.2
Comment #253
j-leeThis is the diff with the code-style/spellcheck fixes.
Comment #256
j-leefix missing change from reroll and fix some deprecations for 9.2
Comment #257
j-leeThe 3 fails are:
But how can this be fixed?
Comment #258
berdirThat's not the reason for the fail, you can ignore that. The reason are the deprecation messages at the end of the output:
Comment #259
j-leeAh ok, Thank you @Berdir.
This patch should (hopefully) fix the deprecations.
Comment #260
j-leeAnd the path for 9.2
Comment #261
j-leeOk, test are green now.
I have fixed deprecated code at Javascript tests and fixed some code styling issues.
Diff files are attached (9.3).
My manual test with a clean Drupal 9.2 installation and the Umami demo were successful.
How can we go further?
Comment #262
j-leeComment #265
j-leeReroll from patch #259 for 9.3
Comment #266
j-leeMissed a few files at #265. So once again ...
Comment #267
aspilicious commentedThis patch fatals for me when visiting the layout page on a translation.
It fails in function"_contextual_links_to_id" on line $route_parameters = UrlHelper::buildQuery($args['route_parameters']); because 'route_parameters' seem to be empty.
I added an empty check around it locally.
Comment #268
p-neyens commentedTo fix following Error: Call to a member function isTranslatable() on null in Drupal\layout_builder\Element\LayoutBuilder->createContextualLinkElement() i have added a extra check to see if the block exists before calling the isTranslatable method.
Comment #269
p-neyens commentedWhen we use an inline block with custom translatable config the translated block configuration is not being displayed in the translation interface.
I found the following issue which fix this for the layout_builder_st module.
So i created a new patch with the same fix.
Comment #270
hswong3i commentedMR re-roll from https://www.drupal.org/project/drupal/issues/2946333#comment-14445267 via 9.4.x-dev, also solve conflict between 9.3.x-dev.
Comment #271
jordik commentedPatch in #269 worked for me, but after a Drupal core update to 9.3.11 it stopped applying with errors in /core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
Here is the re-roll for 9.3.11.
Comment #272
heddnWhat I found is that on initial load of the layout builder page on a translation (/es/node/123/layout) there isn't any inline blocks in the translation language stored/saved. It uses the default langcode ofx-default. This is the case until I actually modify something in layout builder. The implications are that even though I might modify the body field to have new wording in the translation, the FieldBlock block placed in LB still usesx-defaultand loads the body field for _that_ language. Not the translation as expected.edit - this is not the case. I was confused with how the site had modeled the data. On that specific page, someone had copy/pasted the content from the body into an inline block and wasn't using the FieldBlock for body at all.
Comment #273
heddnPlease ignore #272. Still needs a review.
Comment #275
tinytina commentedI'm using patch #271 with dupal core 9.3.15 currently.
I tested translation of new inline block and changing an existing inline block (label and content) - it's working without errors.
Comment #276
heddnI've found a bug in retrieving the active entity for inline blocks. The published node references a block that references a media/image. On view, everything works fine. But when I edit the inline block on the translation, the inline block in the edit form is an older version of the block. Because there is a copy of the block that has
revision_translation_affectedmarked. This is the case even if I delete the translation for the node. The inline blocks for that language are left over as cruft and get resurrected again later when I create a new translation. Or even if I don't create a translation. The old inline blocks are picked instead of the content from the default (original) language.Comment #277
ranjith_kumar_k_u commentedI just commented the unused variables.
Comment #278
heddnThis is the line that seems to be causing my issues. Does anyone remember why we are picking the active/published inline block instead of the one pulled out of section storage configuration?
Comment #279
heddnComment #280
heddnIgnore #279. I removed the wrong line of code.
Comment #283
heddnThe last couple patches won't work. The block has to be active or you run into the dreaded error: "The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved." So back to #277.
Instead I've written a small post update hook that calls a class via
\Drupal::classResolver(). The general idea being that I think we have bad data in the system and we need to make the block revisions that are actually rendering on the site the active ones by cloning them. Now I have to hope (pray) that this problem doesn't resurface again.Comment #285
mikemadison commentedI had been using the patch from comment 271 but it doesn't seem to apply after Drupal core 9.4.1 and none of the newer ones appear to apply w/ core 9.4.2. I am going to re-open this.
Comment #286
nginex commentedHey @mike.madison@acquia.com, try https://git.drupalcode.org/project/drupal/-/merge_requests/1504.patch, it worked well for me for core 9.4.2
Comment #287
mikemadison commentedconfirmed that MR does the trick. setting back, thanks!
Comment #288
ravi.shankar commentedAdded a patch for Drupal 9.4.x.
Comment #290
steinmb commentedPut it back to needs review. Only bugfixes against 9.4.x.
Comment #291
joseph.olstadWould be nice to get this in, there's only two test fails.
Meanwhile we've been using this module in place of the core fix https://www.drupal.org/project/layout_builder_st
Perhaps layout builder should be removed from core and put into contrib? This issue was aiming to be resolved in 8.8.0 but we're now a major release and 4 minor releases later. Wondering how many more years until we decide to remove layout builder from core?
Comment #292
hswong3i commentedRe-roll #288 for 9.5.x-dev
Comment #295
nielsaers commentedWhat still needs to be done to land this one? Only the 2 failing tests?
Comment #296
nginex commentedMR 1504 seems to working well, but I would like to upload a plain diff version of the MR here, so it's fixed patch that will not be overriden by future commits.
Comment #298
anybodyCould someone with the appropriate permissions please change the MR target branch to 10.1.x and create a separate MR against 9.5.x?
I don't seem to have the required permissions, sadly. No idea why.
Comment #299
ravi.shankar commentedI've needed a patch for Drupal 9.5.x for one of my project, patch #292 was not applying so adding a reroll of patch #292 on Drupal 9.5.x. and uploading here, someone else also might needed a patch as well.
Keeping the status to needs work as there are still some work is pending.
Comment #300
dravenkComment #301
sahil.goyal commentedupdating a quick fix for the #299 CCF.
Comment #302
heddnRerolled again.
Comment #304
smustgrave commentedLeaving the needs upgrade path tests as the current test does not do any assertion before running updates.
CC failure but if it was reroll there was failures in 301
Comment #305
nginex commentedTried with MR but the fork is outdated and I can't get 11.x version.
Tried to create an interdiff file, also failed.
So this is reroll MR 1504 against 11.x
Also applicable for 10.1.x
Comment #306
nginex commentedFixed issues from PHPStan
Comment #307
nginex commentedSorry, phpcs issues was missed. Here is a new patch.
Comment #308
nginex commentedThe patch #307 now applies successfully, but need to fix/improve new tests, the full report is available in the job
Comment #309
webfaqtory commentedI have posted a patch in Fix multilingual site's layout edit context issue with TypeError: Argument 1 passed to UrlHelper::buildQuery() must be of the type array, null given as I was getting this error when trying to access a translation's layout builder in D10.1.2.
I have fixed the missing $args['route_parameters'] (they are availabe in $contextual_links['layout_builder_block_translation'] or $contextual_links['layout_builder_inline_block_translation']) and everything now works.
Maybe someone can check why this patch is required and fix the missing $args['route_parameters'] when _contextual_links_to_id($contextual_links) is called. I am using the 2946333-d10-307.patch
Comment #310
gauravvvv commentedI have fixed the cc failure, added use statement for ClientException and updated elseif condition, Attached patch and interdiff for same
Comment #311
smustgrave commentedWas previously tagged for tests and upgrade path which still need to happen.
Did not review as there’s more to don
Comment #312
webfaqtory commentedWe need an update of 2946333-d10-307.patch for D10.2.x. When issuing composer update to update from 10.1.7 to 10.2.0 I'm getting:
Comment #313
marcellinostroosnijder commentedWatch out: #310 is wrong. I think this issue is a fix for https://www.drupal.org/project/drupal/issues/3101231. I'll add the patch there.
Comment #315
heddnRebased the previous MR on a new MR that is based on 11.x. Fixed some obvious cruft that made its way into the patch file. And updated the deprecation strings. But we still have a lot of needs... tags, so this still needs more work.
Comment #319
jordik commentedThe latest MR5956 did not apply on D10.2.3, stopping at core/modules/layout_builder/layout_builder.services.yml.
Here is the re-roll for D10.2. as a patch.
Comment #320
joseph.olstadWent through coding standards errors and made corrections. Also merged the head of 11.x into the branch.
Comment #321
joseph.olstadComment #322
joseph.olstadOnly one small test error left, have to spin up a vanilla environment with the spark theme enabled as well as this patch going in order to figure it out.
Comment #323
joseph.olstad@heddn, this is one of the tests you wrote, one last test fix and it'll be ready to go, can you please have a look?
Comment #324
smustgrave commentedLeft some comments, mostly small stuff.
Leaving needs update path tests though as I didn't see those.
Also such a change seems like will need a change record
Comment #325
webfaqtory commentedI applied the patch 2946333-319.patch by JordiK to D10.2.3 but there is no edit icon when hovering over a block in Layout builder. Also if my patch 3101231-D10-allow-synced-layout-override-translations.patch is not applied then back to the error
TypeError: Drupal\Component\Utility\UrlHelper::buildQuery(): Argument #1 ($query) must be of type array, null givenI have previously used the 2946333-d10-307.patch wich works fine in D10.1.8. I fixed this patch so it applies to D10.2.3 but got the same results. No edit icon for blocks when in Layout builder for a translated node
Comment #327
adwivedi008 commentedRevised #319 as it cleanly applies for D-10.2.x but was facing an issue with the pencil icon on the layout translation page.
Fixed the issue.
Please review and suggest if any other change is required
Comment #328
webfaqtory commentedI applied the revised patch #327 and still don't get the pencil icon on translated pages when in Layout.
The above is what I get when editing the layout of a translated node on a clean install of D10.2.4. Only the drag/drop icon shows anywhere in the block.
Also the existing blocks that had been translated using previous patches (the last one was 2946333-d10-307.patch) are no longer translated with the patch from #327. I fixed the 2946333-d10-307.patch to be D10.2.x compatible and all existing translated blocks have their translations but no pencil icon.
Comment #329
webfaqtory commentedComment #330
s_leu commentedFixed the issue with the note appearing contextual links as mentioned in #325 and #328. To those people who still upload patches in this massive issue: Nobody will see what you changed if you don't at least upload an interdiff along with your patch. But even if you do and there's an MR in the issue, please just use the MR to push your changes, that will make collaboration much easier.
Comment #331
s_leu commentedComment #332
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #333
webfaqtory commentedI'm trying to add the 10.2.x fork to my composer.json (sorry never done this before) I have this under repositories:
But I don't know what to put under require for the 2946333_3049332_combined-10.2.x branch and would it replace the drupal/core requirement?
Comment #338
smustgrave commentedSo you only need 1 MR pointed at 11.x can close the others
Comment #339
eit2103 commentedWas this pushed to the core? Is there a way to translate titles added with Layout Builder without applying a patch now?
Comment #340
j_drupalIt looks like the MR for 10.3 is not working properly.
I am using this patch: https://git.drupalcode.org/project/drupal/-/merge_requests/8480.diff which applies fine, but blocks added with layout builder cannot be translated.
Comment #341
eit2103 commentedWhat does that patch allow us to translate?
Comment #342
almador commentedI'm on Drupal 10.3.1 and using layout_builder_st (Layout Builder Symmetric Translations) with patches for Drupal 10 compatibility, but I've noticed some errors with xdebug and ended with this issue.
Am I right that the patch from this issue should resolve the same thing Layout Builder Symmetric Translations is attempted to fix?
If yes, I'd prefer to remove Layout Builder Symmetric Translations and install the patch, but which patch works for 10.3.x?
Comment #343
joe_carvajalSubscribe to this issue, I think that Symmettric translations should be covered by core, leaving the Asymmettric translations in the already stable contrib module.
Comment #344
langelhc commentedPatch from https://git.drupalcode.org/project/drupal/-/merge_requests/8480
Comment #345
l_vandamme commentedThis patch is causing problems when reverting revisions.
This is because of the getActive call that was added to retrieve the latest version of the block when editing in stead of the saved revision. I believe it was added to prevent EntityChangedConstraint errors, but they were fixed in https://www.drupal.org/project/drupal/issues/3053881.
Steps to reproduce this:
Code that is causing this behavior (in InlineBlock::blockForm()):
I think there might also be other places that this getActive function is called to prevent the error where it is no longer needed.
I would be willing to update the patch, but have not been active in creating it, so I'm not sure about what I might be breaking when removing this code.
Comment #346
anybody@l_vandamme: I think the patch is just a static copy from the MR here. Please adjust it there to proceed with the final fix. Patches can then be downloaded statically from there to use with composer patches for example. Thanks!
layout_builder_st is still not D11 compatible and both maintainers seem inactive and do not repond on PM. Maybe someone should request maintainership until this is fixed?
Comment #349
mysdiir commentedAdded a new 10.3.x backport made with the base of 2946333-11.x-rebase.
MR !10504
Comment #350
almador commentedCould someone clarify if using the MR!10504 is enough to replace the Layout Builder Symmetric Translations functionality?
I'm using Drupal 10.4.0 right now and feel exhausted fighting with layout_builder_st problems, currently, it's not allowing me to clear caches from the Drupal admin interface.
Comment #351
hydra commentedThe MR for @mysdiir worked for my 10.4 setup, thx for that!
I ran into an issue which gave me a hard time to understand whats going on, I'll try my best to describe this:
- Create a new block in a layout
- Save and then switch the language to create a translation for this block
- The block created in the source language now is not shown anymore
What I found out is, that the creation of the translation, created a new revision for all languages. But since blocks in layout_builder are referenced by the block_revision_id, the method isBlockRevisionUsedInEntity in SetInlineBlockDependency no longer returns TRUE when determination of the layout_entity takes place, which will be used to inherit the access to the block. This even get's worse when using a paragraph on that block, which also tries to inherit the access.
I have no idea if the other language versions of the layout should be getting updated or if the isBlockRevisionUsedInEntity method should take the latest affected revision in consideration for it's lookup and of course the block_revision_id from the translation as well (currently it always uses the source for that).
To be sure (because it should be backwards compatible and not changing data) I decided to go for the second approach and created this little helper module, which should be obsolete when this gets fixed, or someone gives me a hint what I am doing wrong :)
Comment #352
l_vandamme commentedRebased the MR from 11.x.
As far as I can tell, it still has issues when editing changed blocks after reverting revisions. I might take a look at that later, for now, it should work as before and apply to 11.x.
Comment #353
smulvih2This would be great to get done, so we don't need to rely on layout_builder_st which has been lagging for D11 support.
Comment #354
wranvaud commentedI had issues with language negotiation, when using the detection method "Content language" (/admin/config/regional/language/detection) there were problems like: the translation link would actually be modifying the original English version or in a more complex situation the interface language would be set to French and the content language would be set to Japanese, the block would appear in Japanese but the translation from the contextual menu would be done to the French version.
I'm adding a fix for this based on the MR!10504 from #348. It applies to 10.4.x as well.
FYI, these were also useful patches if you use these modules:
Paragraphs:
"3090200 - #45 Paragraph access check incorrect revision": "https://www.drupal.org/files/issues/2022-10-26/3084934-13_combine_309020..."
Layout Builder Modal:
"3133695 - Incompatibility with layout builder": "https://www.drupal.org/files/issues/2022-12-15/3133695-13.patch"
Comment #356
wranvaud commentedThis patch applies to the latest release to date D11.2.2. See diff here: Compare with previous version
I've also merged 11.x for the latest 11.x-dev branch so far.
Comment #357
wranvaud commented@useernamee this patch is for drupal core not for the layout_builder_st module. You should choose either the patch to core or the module, they should both ideally provide symmetrical translations.
Comment #359
clayfreemanIt had been a few months since this MR got any updates, so I decided to try to rebase it and solve the test failures (where possible). I was able to resolve all but one failure, and I think it's related to my changes to
core/modules/layout_builder/src/Plugin/Block/InlineBlock.php. (Having this code in place breaks some other assertions in seemingly unrelated Layout Builder tests. Is there documentation regarding why this is needed?)I should also note that the "label_display" element is appearing on the translation form for inline blocks, and I'm not convinced one way or another whether this should be happening. In the case that it should appear, I do believe that it should render as a checkbox instead of a text field (as it currently does). As a workaround for now, I'm forcibly setting it to "1" in tests.
So there are definitely still some testing/usability concerns that need work, but hopefully my efforts can get the ball rolling again on this.
Comment #361
l_vandamme commentedQuick rebase on main + Added a 11.3.2 patch
Comment #362
ezeedub commentedThe BC fallback in
LayoutBuilder::__construct()(introduced in the 2026-01-23 rebase) has an extra "!":if (!$entity_type_manager === NULL)That parses as(!$entity_type_manager) === NULL, which is always false —!$xyields a bool, never NULL — so the deprecation warning and the fallback to\Drupal::entityTypeManager()never run when the constructor is called without the argument. The pre-rebase version used!$entity_type_manager instanceof EntityTypeManagerInterface; the rebase looks like an unintended collapse.Caught (by Claude) while upgrading a site to 11.3.8 against this patch. Interdiff attached.
Comment #363
ezeedub commentedAnother drop in the 2026-01-23 rebase: Plugin/Block/InlineBlock.php is missing the EntityRepositoryInterface injection and the getActive() lookup that were in
2946333-mr5956-1122.patch(2025-06-30).In that earlier patch,
InlineBlock::__construct()took anEntityRepositoryInterface $entity_repositoryparameter and stored it as$this->entityRepository;create()wiredentity.repositoryin; andblockForm()fetched the active translation before building the form:The rebase keeps only the
$element['langcode']['#access'] = FALSE; piece inprocessBlockForm()— the editor-facing consequence is that opening an already-translated inline block renders the source-language content instead of the translation.Interdiff attached to restore the injection and the getActive() call. Caught while upgrading a site to 11.3.8.