Problem/Motivation

I receive a `SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'langcode' cannot be null: INSERT INTO {paragraphs_item}` when saving a paragraph item attached through certain conditions like Layout Builder (see #2901390-15: Integrity constraint violation: 1048 Column 'langcode' cannot be null ).

Steps to reproduce

I get an error when trying to save. The set up is this is a paragraph entity on a media entity being created through entity browser entity form. It seems that the paragraph isn't receiving a langcode from massageFormValues in the InlineParagraphsWidget.

Here is the complete backtrace:

Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'langcode' cannot be null: INSERT INTO {paragraphs_item} (revision_id, type, uuid, langcode) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => pull_quote_with_image [:db_insert_placeholder_2] => 0da9476f-29a9-42b4-9c8d-2de3bba2fd13 [:db_insert_placeholder_3] => ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 777 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Drupal\Core\Database\Statement->execute(Array, Array) (Line: 624)
Drupal\Core\Database\Connection->query('INSERT INTO {paragraphs_item} (revision_id, type, uuid, langcode) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3)', Array, Array) (Line: 87)
Drupal\Core\Database\Driver\mysql\Connection->query('INSERT INTO {paragraphs_item} (revision_id, type, uuid, langcode) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3)', Array, Array) (Line: 32)
Drupal\Core\Database\Driver\mysql\Insert->execute() (Line: 850)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->doSaveFieldItems(Object) (Line: 263)
Drupal\Core\Entity\ContentEntityStorageBase->doSave(NULL, Object) (Line: 392)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 768)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 364)
Drupal\Core\Entity\Entity->save() (Line: 259)
Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem->preSave() (Line: 254)
Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem->preSave() (Line: 244)
Drupal\Core\Field\FieldItemList->delegateMethod('preSave') (Line: 202)
Drupal\Core\Field\FieldItemList->preSave() (Line: 479)
Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldMethod('preSave', Object) (Line: 429)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('presave', Object) (Line: 435)
Drupal\Core\Entity\EntityStorageBase->doPreSave(Object) (Line: 298)
Drupal\Core\Entity\ContentEntityStorageBase->doPreSave(Object) (Line: 389)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 768)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 364)
Drupal\Core\Entity\Entity->save() (Line: 140)
Drupal\entity_browser_entity_form\Plugin\EntityBrowser\Widget\EntityForm->Drupal\entity_browser_entity_form\Plugin\EntityBrowser\Widget\{closure}(Object, 0)
array_walk(Array, Object) (Line: 141)
Drupal\entity_browser_entity_form\Plugin\EntityBrowser\Widget\EntityForm->submit(Array, Array, Object) (Line: 189)
Drupal\entity_browser\Form\EntityBrowserForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 585)
Drupal\Core\Form\FormBuilder->processForm('entity_browser_wysiwyg_embed_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm('entity_browser_wysiwyg_embed_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I see the same error mentioned on this issue.

Could others try this patch too? @TrevorBradley?

Proposed resolution

Patch the paragraph blob to include `langcode`.

Remaining tasks

  • Test the patch in #2901390-82: Integrity constraint violation: 1048 Column 'langcode' cannot be null:
    • If you added a block before applying the patch, then trying to save the layout with that added block, it will not work, because the Layout Builder's intermediate blob state is not being addressed here. What is being addressed here is the process of adding the block via the form. To test if the patch works for you, you need to test with a completely new layout (not with an already existing intermediate state of the layout). IMO it does not make sense trying to fix the intermediate state of blobs. What gets into the blob, stays in the blob.
    • If you still encounter the error - then once more like I already said in #79 please - at least provide a deterministic way to reproduce the error like #80 or even better write an additional Unit / Kernel or functional test. Having an automated test would help us to reduce misunderstandings, we can directly address the problem and proceed with this issue.

User interface changes

n/a

API changes

n/a

Data model changes

n/a

Release notes snippet

@todo

Comments

oknate created an issue. See original summary.

oknate’s picture

Issue summary: View changes
oknate’s picture

this patch seems to fix the issue for me, but I'm not sure if it's the best way.

The paragraph's $paragraphs_entity->get($langcode_key) has a langcode on it, as it's a fieldItemList, and you can set the paragraph's langcode to it.

$paragraphs_entity->set($langcode_key, $paragraphs_entity->get($langcode_key)->getLangcode());

this way the fielditemlist isn't empty, and the bug goes away.

Additionally, I'm adding a check !empty($form_state->get('langcode'), because in my case, $form_state->get('langcode') was null. So it's pointless to run the lines afterward if that value is null.

Note that in this case the form was an entity_browser form.

Not really sure how to give easy steps to reproduce.

zulljin’s picture

Patch #3 working for me. Thanks

johnchque’s picture

Status: Active » Needs review

Let's trigger tests here. :)

johnchque’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

As always we need tests for this. :) Also, a test-only patch so we can ensure that the code fixes the problem.

sgurlt’s picture

It is not working for me with the latest dev version. Do I have to enable some sort of translation functions to have this working?

EDIT: My fault, I just realized that this is just working for the Paragraphs Default Widget and not for the experimental one. I will reroll the patch for this one.

sgurlt’s picture

Here is the rerolled patch for the experimental module. Sorry I ain't got the time at the moment to write tests :/

berdir’s picture

Status: Needs work » Needs review
sgurlt’s picture

StatusFileSize
new2.22 KB

Applied the changes to the wrong method ...

eloivaque’s picture

#10 works for me when use entity browser create content option.

unstatu’s picture

#10 also worked for me

voleger’s picture

Status: Needs review » Reviewed & tested by the community

#10 works for me

miro_dietiker’s picture

Status: Reviewed & tested by the community » Needs work

We can only fix such fatals / errors with test coverage.

twfahey’s picture

Haven't rolled this into a test, but one way to reproduce:
- Enable Layout builder
- Create a Paragraph type, and create a Custom Block Type w/ Entity reference to the Paragraph type
- Enable Layout Builder for Article (or some content type)
- Try adding the Custom Block Type w/ the Paragraph Entity reference as a "Custom Inline Block" to a section on the Article. Can get all the way through adding and placing it, it will show up on the preview.
- When hit Save Layout, the error is triggered.

I don't know if this being the test is complicated by the fact of using Layout Builder, technically still experimental module. Perhaps there is a better way to evaluate I have not come across, but this is my use case that is breaking.

steven buteneers’s picture

I can confirm the problem occurs when following the steps in #15. Patch in #10 fixes the problem (for now).

trigdog’s picture

This happens as well for me with Entity Browser and creating content with paragraph. #10 seems to fix the issue.

Raman Starshykh’s picture

Assigned: Unassigned » Raman Starshykh
Raman Starshykh’s picture

Assigned: Raman Starshykh » Unassigned
mhdev90’s picture

#10 works for me, thanks!

gun_dose’s picture

Status: Needs work » Reviewed & tested by the community

I have the same situation, as #15, and patch from #10 solved my problem, so I change issue status to RTBC.

miro_dietiker’s picture

Status: Reviewed & tested by the community » Needs work

We can only fix such fatals / errors with test coverage.

trevorbradley’s picture

Another +1 to patch #10. This time coming from editing paragraphs using Views Bulk Edit.

Are all of us coming from "Paragraphs-adjacent" use cases?

hanoii’s picture

Issue summary: View changes
StatusFileSize
new4.02 KB

I needed this. While the patch on #10 does fix the issue, I am not sure on the implementation

  1. +++ b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
    @@ -1273,7 +1273,11 @@ class InlineParagraphsWidget extends WidgetBase {
    +        $paragraphs_entity->set($langcode_key, $paragraphs_entity->get($langcode_key)->getLangcode());
    

    I don't understand this line, ain't it setting something from what was already set with the same thing?

  2. +++ b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
    @@ -1273,7 +1273,11 @@ class InlineParagraphsWidget extends WidgetBase {
    +        if (!empty($form_state->get('langcode'))
    

    I think this one is the actual line that fixes this error

Having said the above, just ignoring the the langcode null might still cause issues later on.

I debugged this trying to come up with a better idea. I actually don't think the root cause of the error is on this module, but rather inline_entity_form.

What I found out is that when the paragraph widget is rendered normally on an entity form, https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21... is run, but this code is never run when using entity_browser and inline_entity_form.

I am proposing a different approach, which is still a bandaid but one that I believe could prevent more issues related to this appear elsewhere.

I set my local up for testings and will try to add a test at some point, so leaving it at Needs work.

fenstrat’s picture

Also hit this. Agreed that #24 is a better approach than #10.

+++ b/src/Plugin/Field/FieldWidget/ParagraphsWidget.php
@@ -2284,6 +2284,35 @@ class ParagraphsWidget extends WidgetBase {
+  protected function initFormLangcodes(FormStateInterface $form_state, ContentEntityInterface $host) {

Might make sense to split this out into a ParagraphsWidgetBase to avoid duplicating it in both InlineParagraphsWidget and ParagraphsWidget?

pcate’s picture

I just updated to 8.7 and ran into this bug when I tried adding a custom block type with Layout Builder. The block type had a paragraph reference field on it. After adding it to a page with LB as an inline block the error occurred. Neither patch #10 or #24 fixed the issue.

Update: Actually, I spoke too soon. Patch #24 did work when adding new blocks with paragraph fields in LB.

sepapp2’s picture

While patch #24 works to resolve that issue in LB it causes an issue while using content moderation. Any content sent to a draft state with a paragraph is no longer viewable or editable in LB.
When trying to view a draft in LB instead a user gets this message.
"You are not allowed to view this Paragraph.
You are not allowed to edit or remove this Paragraph.
"

chris burge’s picture

#24 tests successfully for me. I agree with #25 re code duplication.

@sepapp2 - Re #27, what is the behavior before this patch? I suspect the issue described in #27 may be unrelated.

chris burge’s picture

StatusFileSize
new4.02 KB
new6.58 KB

Attached patch is #24 but the duplicate code is moved to a trait. Leaving at 'Needs work' so a test can be written.

lakshmi_a’s picture

Assigned: Unassigned » lakshmi_a
lakshmi_a’s picture

in database go to langcode field check the NULL option.

lakshmi_a’s picture

Assigned: lakshmi_a » Unassigned
Status: Needs work » Needs review
finex’s picture

Hi, the patch works as expected: the error has gone.

Should https://www.drupal.org/project/entity_browser/issues/3014194 be closed as duplicate?

P.S: I've updated the patch for current -dev version.

acbramley’s picture

@FiNeX #29 still applies cleanly to the latest dev release and you've made changes to the patch without providing an interdiff or explaining what you've done. Is there a reason you changed both langcodes to $language = \Drupal::languageManager()->getCurrentLanguage()->getId();? This doesn't seem right to me.

finex’s picture

@acbramley: when I've tested the patch #31 I was not able to cleanly apply it so I've applied manually and I've recreated the patch. The code you're pointing has been introduced on #31. I've only updated the patch #31 for the current -dev.

acbramley’s picture

Status: Needs review » Needs work

Sorry @FiNeX you're right, I skipped looking at #31 since it didn't apply cleanly.

I think we should still consider #29 as the correct approach here. Setting back to NW for tests.

redbrickone’s picture

Following. I tried several of these patches and still receive the error. I'm running paragraphs 8-1.9 on Drupal 8.7.0

p4trizio’s picture

I had this problem with a paragraph field in a block type using the layout builder. Patch in #29 solves the issue for me

stopopol’s picture

I had a problem with batch-updating nodes and their paragraphs the patch in #29 just applied cleanly and solved the issue

capysara’s picture

Patch in #29 resolves the error and applies cleanly to 1.10.

pcorbett’s picture

Similar setup as #15 with 1.10 and patch applied cleanly and fixed issue.

Coops_’s picture

Confirming patch #33 works for me.

spleshka’s picture

I confirm that #33 works perfectly fine for me. Thank you @FiNeX.

phjou’s picture

#33 worked for me too in the context of a field on a custom block placed on Layout Builder.

kingdutch’s picture

Spotted a typo in patch of #29. If you're coming to this issue please test/review/improve that patch (as per discussion in 34/36)

@see ContetEntityForm::initFormLangcodes() Should be ContentEntityForm :)

jamesdixon’s picture

#33 fixed this issue for me.

ngkoutsaik’s picture

Hi,

I stumbled on this error while reviewing this issue. Specifically, at the "Save layout" I got the error. Applying patch #33 fixed the error for me.

I will leave this to needs work as it still needs tests.

seaarg’s picture

#33 fixed the issue for me in version 8.x-1.11

Minor issue: The patch have some spacing (tabs) issue at file src/Traits/FieldWidgetTrait.php

Webbeh’s picture

StatusFileSize
new173.29 KB
new599 bytes

Adding another +1 to #29 fixes the issue on new Paragraph entities embedded within a Custom Block on a Layout per the guidance in #15. I did have to recreate the entities to inherit the langcode, but it did work.

Marking still 'Needs Work', per #2901390-47: Integrity constraint violation: 1048 Column 'langcode' cannot be null:

I will leave this to needs work as it still needs tests.

However, I am extending the work of #29 with the small typo change in #45.

Patch and interdiff attached. Typo down, now let's get some tests written and get this into a release.

lpeabody’s picture

The above patch seems to include an unnecessary .orig.

Webbeh’s picture

Whoops, thanks for catching the unnecessary .orig - updated my helper patching tool to mitigate that moving forward.

Re-rolling #29 with changes as requested in #45.

simgui8’s picture

#51 applies cleanly to 1.12 and fixes the error for me when adding a paragraph field to a layout builder content.

Thanks

dmouse’s picture

#51 works for me too. Thank you @webbeh

vlklavanya’s picture

#51 worked for me. Thanks for the patch @webbeh.

nitheesh’s picture

Status: Needs work » Reviewed & tested by the community

#51 works for me too on a layout builder paragraph block.

jnettik’s picture

Also tested #51 using Layout Builder and it worked for me.

mpastas’s picture

#51 worked for me. Subscribing.

nessthehero’s picture

Also confirming #51, and reiterating for any new visitors that if you have any existing entities created before you apply the patch, you'll still get the error, and must delete them and recreate them to see the fix.

niklan’s picture

#51 works well

i-trokhanenko’s picture

+1 RTBC, #51 works well for me

jonas139’s picture

I can also confirm #51 works. Thanks to all for the efforts!

robertinop’s picture

I've also used #51 to solve this issue in the Views Entity Form Field queue:

https://www.drupal.org/project/views_entity_form_field/issues/3067248.

My thanks as well for all the good work.

akshayadhav’s picture

#51 works great! Thanks @Webbeh!

markusa’s picture

Patch in #51 works for me. Thank you!!! D8.9 + Paragraphs 1.12

jeremyr’s picture

Is anything else needed on this; can it be rolled into a release?

Zuzuesque’s picture

The patch in #51 worked great for us. Thanks for the work!

D9.0.1 + Paragraphs 1.12

phjou’s picture

#51 works for me as well when using paragraphs with layout builder.

mxh’s picture

Status: Reviewed & tested by the community » Needs work

Is anything else needed on this; can it be rolled into a release?

We still need automated test coverage for this, before it could be set as RTBC.

Besides that, ATM I don't agree with the implemented approach of patch #51. As for the $form_state->set(...) calls I see there, it seems to handle the symptom, not solving the root cause. Other inline-embedded entities not being paragraph types seem to work properly, thus it might be something wrong with setting the langcode values of new paragraph entities. It might happen during the logic of the widget plugins, but I'm not sure whether the form state is the right place to manipulate there.

mxh’s picture

Results from performing a manual test using the case of #15: Patch from #51 has the effect, that the fatal error described in issue summary doesn't appear anymore and the paragraph items will be saved in the database. But it introduces a new bug.
Steps to reproduce:
- Have multiple languages installed, use one as default language for creating new custom blocks (e.g. English).
- Create an inline block within the Layout Builder, using a custom block that uses paragraphs.
- Within the block form, choose another language that differs from the default language selected (e.g. German).
- Add the inline block having at least one paragraph item and save the layout.
Result:
- The block_content instance is saved with the chosen language (correct)
- The paragraph items belonging to the block_content instances have the default langcode (wrong, should be same as block_content).

Also when trying to change the language of an already existing inline block, the paragraph items will be always updated with the previously set langcode of the parent instance, not the (probably changed) submitted langcode.

mxh’s picture

Assigned: Unassigned » mxh

Trying to work on a solution, focussing on use case #15.

mxh’s picture

Assigned: mxh » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new21.67 KB
new14.67 KB

Feel free to add "Needs tests" tag again if the written one is not enough (or wrong).
No interdiff provided as it's another approach.
Please review and test this one for your use cases. It works on my use case for using Layout Builder's inline blocks with paragraph fields.

mxh’s picture

StatusFileSize
new14.73 KB
new21.72 KB

Same as #71, only trying to make it compatible with tests running with D8.

The last submitted patch, 72: paragraphs-2901390-72-testsonly.patch, failed testing. View results

acbramley’s picture

Status: Needs review » Needs work

There's a bug in #72 which doesn't exist in #51 where removing a paragraph item and resaving the block triggers a similar error when saving the layout:

Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'langcode' cannot be null: UPDATE {paragraphs_item} SET "revision_id"=:db_update_placeholder_0, "type"=:db_update_placeholder_1, "uuid"=:db_update_placeholder_2, "langcode"=:db_update_placeholder_3 WHERE "id" = :db_condition_placeholder_0; Array ( [:db_update_placeholder_0] => [:db_update_placeholder_1] => link [:db_update_placeholder_2] => c111cd8b-8414-4c7f-9aa9-9124a6a2aa9f [:db_update_placeholder_3] => [:db_condition_placeholder_0] => 21973 ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 810 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php). 

To reproduce:

  1. Create a block with multiple paragraph items in a single field
  2. Save the block + page
  3. Re-edit the layout and block and remove a paragraph from the middle of the list
  4. Re-save the layout
mxh’s picture

I'm trying to reproduce #74, but no luck so far.
I'm using the Layout Builder's standard layout form (no modal extension, also no further module like symmetric translations etc.). I use the "create custom block" element (inline block). I always first click on "Update" within the inline block form and then save the layout.
All my content entities are configured to be translatable and use the site's default language as default language. I have the language field enabled within the form, but also tried to reproduce without having the field enabled.

There seems to be a constellation in site configuration which might lead to the case of #74. Could you please maybe try to provide a little bit more details about that constellation? An automated test which leads to that case could help too.

Edit: I tried to reproduce #74 on a fresh standard profile using Paragraphs, Layout Builder and a content block with a paragraphs field. I placed it within Layout Builder via inline block form. Unfortunately still no luck on reproducing the case. Could maybe someone try it too, and if reproduced, provide configuration details?

amol.palhade17’s picture

Version: 8.x-1.x-dev » 8.x-1.12
Assigned: Unassigned » amol.palhade17
StatusFileSize
new6.91 KB

Hello Everyone,

First of all I want to thanks everyone who is working on this issue. I checked the code and tried to apply the patch which is mentioned in the comment #72. The patch didn't got applied because of some reason. However, with reference to patch at comment #72, I made some changes based on the current version.

romainj’s picture

Patch #76 works for me.

phjou’s picture

I got the same issue as #74 when using paragraph in layout builder. It happened in a nested paragraph though. The website is only in english.

mxh’s picture

Assigned: amol.palhade17 » Unassigned
Issue tags: +Needs tests

It seems we cannot make progress without an automated test written for the use case mentioned in #74 / #78, or please provide more details. Of course we still can discuss other options, but I think due to the complexity it surely helps if we have more tests to reproduce the remaining problems.

rogeriocc’s picture

I got the same issue as #74 using patch #76 and #72, when using paragraph in layout builder.

1- Create a block with multiple paragraph items in Layout Builder
2- Save the block
3- Save node
4- Re-edit the layout and block, remove a paragraph and add another.
4- Re-save the layout

Site only in english.

PHP 7.4.7, MYSQL 5.7.16, Drupal 9.1.4

Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'langcode' cannot be null: UPDATE {paragraphs_item} SET "revision_id"=:db_update_placeholder_0, "type"=:db_update_placeholder_1, "uuid"=:db_update_placeholder_2, "langcode"=:db_update_placeholder_3 WHERE "id" = :db_condition_placeholder_0; Array ( [:db_update_placeholder_0] => [:db_update_placeholder_1] => banner [:db_update_placeholder_2] => b29b6335-1d35-4c65-b6a7-134805d73da0 [:db_update_placeholder_3] => [:db_condition_placeholder_0] => 182 ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 810 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

sarguna raj m’s picture

Still I'm getting the below issue when updating the existing paragraph or removing the existing paragraph on the layout builder of a node.

This issue occurs with and without applying the patch #76 and #72.

Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'langcode' cannot be null: UPDATE {paragraphs_item} SET revision_id=:db_update_placeholder_0, type=:db_update_placeholder_1, uuid=:db_update_placeholder_2, langcode=:db_update_placeholder_3 WHERE id = :db_condition_placeholder_0; Array ( [:db_update_placeholder_0] => [:db_update_placeholder_1] => 33_33_33_image_with_text [:db_update_placeholder_2] => 6ef454bb-0f05-46ba-b087-c86e51a70c2f [:db_update_placeholder_3] => [:db_condition_placeholder_0] => 18 ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 846 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

mxh’s picture

Status: Needs work » Needs review
StatusFileSize
new23.67 KB
new8.41 KB

Let's try with this one.

sarguna raj m’s picture

StatusFileSize
new553.63 KB

Hi @mxh,

Applied the patch #82 but no luck still facing the issue. Please find the attachment.

mxh’s picture

Some notes:

  • If you added a block before applying the patch, then trying to save the layout with that added block, it will not work, because the Layout Builder's intermediate blob state is not being addressed here. What is being addressed here is the process of adding the block via the form. To test if the patch works for you, you need to test with a completely new layout (not with an already existing intermediate state of the layout). IMO it does not make sense trying to fix the intermediate state of blobs. What gets into the blob, stays in the blob.
  • If you still encounter the error - then once more like I already said in #79 please - at least provide a deterministic way to reproduce the error like #80 or even better write an additional Unit / Kernel or functional test. Having an automated test would help us to reduce misunderstandings, we can directly address the problem and proceed with this issue.
Webbeh’s picture

Issue summary: View changes

Added clarifiers and to-do's from 84 into original issue to hopefully encourage productive testing and edge-case issue reproduction.

Reformatted issue to hopefully give a brief synopsis of the issue.

kim.pepper’s picture

Issue tags: +#pnx-sprint
paulmckibben’s picture

Confirming the patch in #82 fixes the issue for me.

pameeela’s picture

Patch in #82 fixed it for me too, thanks!

capysara’s picture

Using Drupal 9.2.1 and paragraphs 8.x-1.12, #82 applies cleanly via composer and resolves the issue. I started with a new layout as noted in #84. Thank you!

mxh’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests, -#pnx-sprint

In case anyone might still experience issues with patch from #82, please report accordingly, best case would be to reproduce with further Unit/Kernel/etc tests.

kclarkson’s picture

I am also confirming that patch in #82 is applied cleanly and is working as expected.

manish34jain’s picture

Patch #82 fixed the issue, Thanks!!!

gnuget’s picture

I just wanted to confirm too that #82 is working for me as well.

Thanks!

mxh’s picture

I currently don't know how we could push this any further to get it fixed. Do we need more tests?

podarok’s picture

#82 works for us in Open Y distribution. Thanks
+1 RTBC

tce’s picture

#82 fixed the issue I was having with a paragraph widget in a custom form. Thanks

Webbeh’s picture

I currently don't know how we could push this any further to get it fixed.

I would assume at this point, our remaining tasks were to determine if anyone has any issues after application of #82. I haven't seen any real concerning impact, so we should probably reach out to the maintainers (via Drupal Slack or email) and ping them about this issue, as it would be great to get this issue resolved.

berdir’s picture

Maintainers have been pinged and aware of the issue. Will try to find some time to get it committed.

robbdavis’s picture

#82 applied perfectly and fixed the breaking error I had when adding a paragraph to custom block.

clayfreeman’s picture

Version: 8.x-1.12 » 8.x-1.x-dev

Moving to 8.x-1.x-dev and queuing a retest.

vacho’s picture

This issue happens with Drupal core 9.3.3 also

danwonac’s picture

#82 failed to fix the error for me on D9.3.5. Our use case is adding a block type containing a paragraph within layout builder.
Edit: had "The URL alias field needs to be installed", fixing that fixed the issue with the patch.

berdir’s picture

This is a complex change and not too fond of adding (another) entity to the form structure that is then serialized, that won't help with performance. But I also understand that this apparently helps a lot of people so I'll commit this.

Did clean up the test a bit, D9 deprecations and not fond of random machine names and labels, that just makes debugging something harder. Also renaming widget references, it's legacy/stable now, not classic/experimental.

  • Berdir committed 7596d70 on 8.x-1.x
    Issue #2901390 by mxh, Webbeh, sgurlt, Berdir, Chris Burge, oknate,...
berdir’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Note that this isn't in the 8.x-1.13 release, I deliberately did that first, so this can be tested a bit more in the dev release.

Status: Fixed » Closed (fixed)

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

damontgomery’s picture

#103 seems to work for us. Only used it a little, but the errors went away and we can add inline blocks to layout builder when multilingual is used on the site.

taraskorpach’s picture

#103 is not applied for D9.4.5. Will you be updating it?

leo liao’s picture

StatusFileSize
new1.83 KB

This patch is modified according to #10. Although part of the code in this issue has been merged, the problem still exists. When I apply paragraphs in a block, this block is applied in layout build. When saving the layout, this error will be prompted.
drupal version is 10.1

prashant.c’s picture

The bug does exist in Drupal 11 also, while using paragraph reference field in block types, currently using patch from #109, but not sure if it could cause issue somewhere else or will continue to work properly.

Thanks