area17 / twill

Twill is an open source CMS toolkit for Laravel that helps developers rapidly create a custom admin console that is intuitive, powerful and flexible. Chat with us on Discord at https://discord.gg/cnWk7EFv8R.
https://twillcms.com
Apache License 2.0
3.8k stars 577 forks source link

Restore Revision on Entity with Blocks & Nested Repeaters causing unexpected Blocks Rows #2660

Open deckchan opened 2 months ago

deckchan commented 2 months ago

Description

When the entity contains blocks, the blocks with repeaters, the restore revision function will cause many unexpected rows in blocks table. And these rows will keep forever and now my production site contains several thousands rows causing very slow performance.

Steps to reproduce

Create a very simple structure to reproduce: Make a Module eg. Page Page Has Blocks

Save data like this:

Publish.

Database blocks would look like this:

image which is good.

And I Edit 3 buttons, change "Button Test 7" -> "Button Test 7 edited" "Button Test 8" -> "Button Test 8 edited" "Button Test 9" -> "Button Test 9 edited"

Update

Database blocks would look like this:

image which is also good.

And we do the "restore" action to last revision.

image

Expected result

Expect result should be no additional rows are added, just normal as previous database screencap.

Actual result

However, unexpected rows are added:

image

at id (398, 399, 400, 401)

And these rows seem keep forever, and many other rows would produced everytime restore revision.

And these rows should affecting the performance.

Versions

Twill version: 2.11.0 Laravel version: v9.52.16 PHP version: PHP 8.1.23 Database engine: MySQL 8.0.30

deckchan commented 2 months ago

Attach

resources/views/admin/blocks/simple.blade.php
resources/views/admin/pages/form.blade.php
resources/views/admin/repeaters/button.blade.php
resources/views/admin/repeaters/simple_item.blade.php

simple-blocks.zip

zeezo887 commented 2 months ago

Hi @deckchan, this issue has been fixed in the latest version of Twill 2. I'd suggest you upgrade twill to 2.13.0.

deckchan commented 2 months ago

@zeezo887

I have just tested with 2.13.0, the issue still exists

image

image

Versions

Twill version: 2.13.0

Laravel version: v9.52.16

PHP version: PHP 8.1.23

Database engine: MySQL 8.0.30