Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Bloqs are not saving in nested state

Status Resolved
Add-on / Version Bloqs 4.6.0
Severity
EE Version 6.0.3

Nigel

Mar 14, 2021

When I nest bloqs that have been setup to accept children/parent it will un-nest when saved. The video below demonstrates this

https://www.icloud.com/iclouddrive/08i2flwMLGM4hpau1qY4za2sg#Un-nested-bloqs

I have also tried this with templates, again a video of this in action:

https://www.icloud.com/iclouddrive/09IoaBqRiFjQKeW2E2uCFli6Q#bloqs_unnested_2

Thank you

#1

BoldMinded (Brian)

Mar 14, 2021

This too is also probably because of the max input vars issue. I bet if you save an entry with 3 nested Bloqs it saves fine, but an entry with a lot of Bloqs doesn’t save.

#2

Nigel

Mar 15, 2021

So I have tried to create a fresh entry with only 3 blocks.

Two blocks nested under one. On save all blocks are un-nested.

I have also increased the max_input_vars to 5000. Still no joy!

https://www.icloud.com/iclouddrive/0MVfnLXd0sj_FGtJioq-BhoVw#Unnested-5000-vars

#3

Nigel

Mar 15, 2021

The above video shows my attempt with a template. But I have also tried with plain single bloqs.

#4

Nigel

Mar 15, 2021

To provide more information on what I am seeing, on First save only, does this un-nesting seem to happen.

#5

BoldMinded (Brian)

Mar 15, 2021

Any JS errors in your console?

#6

BoldMinded (Brian)

Mar 15, 2021

#7

Nigel

Mar 15, 2021

No errors in the console. I had tried Safari and Chrome.

#8

BoldMinded (Brian)

Mar 15, 2021

And what about the field setting? Is it set to nestable? Did you try this with normal bloqs? E.g. not a template?

https://docs.boldminded.com/bloqs/docs/features/bloq-templates#bloq-templates-and-non-nested-fields

#9

Nigel

Mar 15, 2021

The field setting has always been set to nestable. I have tried with normal bloqs.

Video showing settings

https://www.icloud.com/iclouddrive/0MN6C9b378FopSIaMJXw8s_2w#unnested-show-settings

#10

Nigel

Mar 15, 2021

I’m assuming you are seeing the videos I have made?

#11

BoldMinded (Brian)

Mar 15, 2021

Comment has been marked private.

#12

Nigel

Mar 15, 2021

Thanks. No joy. The un-nesting.

It appears I that on first save, it will wipe all but two bloqs and any data I had inputted!

I uninstalled the plugin and re-installed it. So working with fresh bloqs.

I have my bloq field that has nesting enabled.

I have a grid wrap bloq that can accept children

I get a bloqs save error:

Bloqs save error: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'data' cannot be null:
INSERT INTO exp_blocks_atom (`block_id`, `atomdefinition_id`, `data`) VALUES (2, 3, NULL) ON DUPLICATE KEY UPDATE data = NULL#0 /site-path/system/ee/legacy/database/drivers/mysqli/mysqli_driver.php(112): CI_DB_mysqli_connection->query('INSERT INTO exp…') #1 /site-path/system/ee/legacy/database/DB_driver.php(260): CI_DB_mysqli_driver->_execute('INSERT INTO exp…') #2 /site-path/system/ee/legacy/database/DB_driver.php(175): CI_DB_driver->simple_query('INSERT INTO exp…') #3 /site-path/system/user/addons/bloqs/Database/Adapter.php(1446): CI_DB_driver->query('INSERT INTO exp…') #4 /site-path/system/user/addons/bloqs/Database/Adapter.php(936): BoldMinded\Bloqs\Database\Adapter->query('INSERT INTO exp…', Array) #5 /site-path/system/user/addons/bloqs/Controller/PublishController.php(831): BoldMinded\Bloqs\Database\Adapter->setAtomData(2, 3, NULL) #6 /site-path/system/user/addons/bloqs/ft.bloqs.php(454): BoldMinded\Bloqs\Controller\PublishController->save(Array, 775, false) #7 /site-path/system/ee/legacy/libraries/api/Api_channel_fields.php(377): Bloqs_ft->post_save(' ') #8 /site-path/system/ee/ExpressionEngine/Model/Content/FieldFacade.php(220): Api_channel_fields->apply('post_save', Array) #9 /site-path/system/ee/ExpressionEngine/Model/Content/ContentModel.php(74): ExpressionEngine\Model\Content\FieldFacade->postSave() #10 /site-path/system/ee/ExpressionEngine/Model/Channel/ChannelEntry.php(385): ExpressionEngine\Model\Content\ContentModel->onAfterSave() #11 [internal function]: ExpressionEngine\Model\Channel\ChannelEntry->onAfterSave() #12 /site-path/system/ee/ExpressionEngine/Service/Model/Model.php(818): call_user_func_array(Array, Array) #13 /site-path/system/ee/ExpressionEngine/Service/Model/Query/Update.php(49): ExpressionEngine\Service\Model\Model->emit('afterSave') #14 /site-path/system/ee/ExpressionEngine/Service/Model/DataStore.php(275): ExpressionEngine\Service\Model\Query\Update->run() #15 /site-path/system/ee/ExpressionEngine/Service/Model/DataStore.php(240): ExpressionEngine\Service\Model\DataStore->runQuery('Update', Object(ExpressionEngine\Service\Model\Query\Builder)) #16 /site-path/system/ee/ExpressionEngine/Service/Model/Query/Builder.php(71): ExpressionEngine\Service\Model\DataStore->updateQuery(Object(ExpressionEngine\Service\Model\Query\Builder)) #17 /site-path/system/ee/ExpressionEngine/Service/Model/Model.php(353): ExpressionEngine\Service\Model\Query\Builder->update() #18 /site-path/system/ee/ExpressionEngine/Model/Content/ContentModel.php(219): ExpressionEngine\Service\Model\Model->save() #19 /site-path/system/ee/ExpressionEngine/Controller/Publish/AbstractPublish.php(377): ExpressionEngine\Model\Content\ContentModel->save() #20 /site-path/system/ee/ExpressionEngine/Controller/Publish/Edit.php(501): ExpressionEngine\Controller\Publish\AbstractPublish->saveEntryAndRedirect(Object(ExpressionEngine\Model\Channel\ChannelEntry)) #21 [internal function]: ExpressionEngine\Controller\Publish\Edit->entry('775') #22 /site-path/system/ee/ExpressionEngine/Core/Core.php(251): call_user_func_array(Array, Array) #23 /site-path/system/ee/ExpressionEngine/Core/Core.php(111): ExpressionEngine\Core\Core->runController(Array) #24 /site-path/system/ee/ExpressionEngine/Boot/boot.php(161): ExpressionEngine\Core\Core->run(Object(ExpressionEngine\Core\Request)) #25 /site-path/admin.php(154): require_once('/Users/nigelpet…') #26 {main}

 

#13

BoldMinded (Brian)

Mar 15, 2021

Are you sure the uninstall completely removed the blocks tables? Based on that error message the uninstall wasn’t performed correctly, or you saved an entry and it inserted data, and then somehow re-saving it is trying to update the data but is failing to do so.

What version of MySQL are you using?

Can you run this query and share the result:

SHOW CREATE TABLE `exp_blocks_atom`;

The last build I sent is saving nested bloqs in a template, and not in a template just fine in my local environment. Since I can’t replicate this, you’ll need to share CP and FTP access to a dev environment where this is happening so I can take a look.

#14

Nigel

Mar 16, 2021

Comment has been marked private.

#15

BoldMinded (Brian)

Mar 16, 2021

Can you provide CP and FTP access, and point me to the entry that is throwing this error when you attempt to save it? Does this error happen when saving any entry or just a specific one?

#16

BoldMinded (Brian)

Mar 16, 2021

My guess is that is not happening on every entry, so you might have to delete the bloqs in the entry that the error is occurring in and re-create them. The data column correctly does not allow NULL as a value, but if the field does not have a value, it should be set to a blank string in the database, which is allowed. If that error is repeatedly happening, then something is incorrectly trying to set that field value to NULL, which it should not be doing. I just did a clean install of Bloqs locally and created a Bloq Template and it’s saving everything fine, including fields with no values. So if you’re still seeing that error, then I need CP and FTP access before I can take any further action.

#17

Nigel

Mar 16, 2021

Comment has been marked private.

#18

BoldMinded (Brian)

Mar 16, 2021

Can you edit the ticket and use the provided fields for fro info? Having it in a comment is less secure. I’m going to edit your comment and remove the info.

#19

Nigel

Mar 17, 2021

Info updated.

#20

Nigel

Mar 17, 2021

I tried to push forward as Im on a deadline. But I can also see that relationship bloqs are not saving with the selected relationship data. But I assume this is related to the error message.

#21

BoldMinded (Brian)

Mar 17, 2021

Please direct me to a specific entry id where’re I can see this happen. Do specific Bloqs need to be on the page? I need steps to replicate. Thanks.

#22

Nigel

Mar 17, 2021

When I copied over your new build I had re-installed it first. I assumed that there may be new bits that needs to be installed.

The channels that I am using with bloqs are pages and sectors.

If I:
- Add “Grid Wrapper” and nest “Ideas Image Block” under it.
- Add a related collection
- Add Image

On save:
-  The error appears
- The blocks are un-nested
- The data is not saved

This is on every new entry I have tried the error appears.

 

 

#23

Nigel

Mar 17, 2021

Comment has been marked private.

#24

BoldMinded (Brian)

Mar 17, 2021

Can you make that user admin access so I can look at the database, logs etc?

#25

Nigel

Mar 17, 2021

Should be there now.

#26

BoldMinded (Brian)

Mar 17, 2021

The FTP login didn’t work.

Can you either fix that, or update line 927 of the Database/Adapter.php file to this:

'data' => $data === null ? '' : $data

Looks like your MySQL engine is set to strict mode, which hasn’t really been a problem in the past so I’m surprised this error is just now occurring. If that code change doesn’t fix it, then I’ll definitely need the FTP access fixed so I can debug it a little closer.

#27

BoldMinded (Brian)

Mar 17, 2021

Actually your MySQL strict mode setting is the same as my local machine. The issue appears to be specific to saving a bloq with a Relationship field in it. Other fields seem fine. Still, this isn’t reported by anyone else and I can’t replicate it locally, so this is s little puzzling.

#28

BoldMinded (Brian)

Mar 17, 2021

Ok, I was able to replicate this locally actually, and it does seem specific to the Relationship field. I wonder if something changed in EE 6.0.2 or .3 to cause this, because this has not been an issue before. The code change in comment 26 is what fixed it for me. So you _should_ be good to go when you make that change.

#29

Nigel

Mar 17, 2021

Hey thanks. I have added the line. You are right the code change stops the error.

However I still experience the un-nesting on save.

Adding new bloqs and duplicating nested bloqs

https://prototype.aguafabrics.com/admin.php?/cp/publish/edit/entry/781

I have updated the ftp settings. Username and Password.

#30

BoldMinded (Brian)

Mar 17, 2021

Ok, I think I fixed it. Not sure how this regression happened b/c I’m pretty sure I tested this thoroughly. Oh well. In the cp.js file, line 216, change it to this:

var $blockCollection = $blocks.find('.blocksft-block:visible').not('.blocksft-block--utility');

Then it should work.

#31

Nigel

Mar 17, 2021

I get your pain.

No joy with that either :/

I have replaced that line. Doubled checked by loading up EE Admin in a Chrome Incognito browser and viewing the cp.js file in the Network tab. Ln 216 has:

var $blockCollection = $blocks.find('.blocksft-block:visible').not('.blocksft-block--utility');
#32

BoldMinded (Brian)

Mar 17, 2021

Comment has been marked private.

#33

Nigel

Mar 17, 2021

So that seems to have done it :D

Thanks for your help with this.

#34

Nigel

Jul 08, 2021

So I have had this project go live with content editors. Unfortunately, the un-nesting on save is still an issue. As you can imagine this is undermines the clients experience, so I am very keen to find a solution for this issue.

I have tried updating to the latest version of 4.7.1
I am running EE 6.0.6
I have run back through the thread to ensure I have applied the max_input_vars

One thing I have noted is, the un-nesting on save appears to only happen when a nested block contains a image/file field.

It seems we are closer to perfection. Really appreciate your help with this.

Thanks

#35

BoldMinded (Brian)

Jul 08, 2021

Do the blocks that are un-nesting have a File field in them by chance?

#36

Nigel

Jul 09, 2021

Yes. Yes they do.

I tested a block with just the image field inside it and that is always un-nested.

#37

BoldMinded (Brian)

Jul 09, 2021

I ran into this just this week when working on a refactor. It was a pain to chase down, but the fix is easy. I’ll send a new build later today.

#38

BoldMinded (Brian)

Jul 09, 2021

Comment has been marked private.

#39

Wardour

Jul 10, 2021

Comment has been marked private.

#40

BoldMinded (Brian)

Jul 10, 2021

I might have sent the wrong build. I’ll send another one on Monday.

#41

BoldMinded (Brian)

Jul 11, 2021

Ok, you might need to make the update yourself. It’s an easy fix. Revert your Bloqs folder to the previous version you had, disregard that new build I sent, and make this change to the version you were running.

Login to reply