Project

General

Profile

Actions

Bug #101798

open

Prevent saving unchanged inline records to save performance

Added by Sebastian Michaelsen 8 months ago. Updated 8 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2023-08-30
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Problem

When you have a record, which has 10 inline items and the record is translated (along with the inline items) into 10 languages, then saving the record even with no changes to the inline items causes the DataHandler to save 110 database records which can take some 30 seconds.

Why is that?

The inline records have toggles to hide/unhide them (unless the table does no support that), which means when saving the record there will be a `someid => ['hidden' => '0']` entry for each inline item, which causes DataHandler to save that inline item, which then also triggers saving of its translations.

Solution(?)

It could be solved in backend JavaScript, so that the inline `hidden` form fields are only included in the request when their value was changed.

Workaround

For our project I created a backend middleware, that intercepts the `data` when a record is saved and removes any entries, that have just the hidden field and it is unchanged. (Yes, I create a database request for each of those entries but it's still way faster than before)


Files

PreventSavingUnchangedInlineRecords.php (2.99 KB) PreventSavingUnchangedInlineRecords.php workaround middleware Sebastian Michaelsen, 2023-08-30 11:27
Screenshot_2023-08-30_at_13_37_14.png (475 KB) Screenshot_2023-08-30_at_13_37_14.png Sebastian Michaelsen, 2023-08-30 11:41
Actions #1

Updated by Andreas Kienast 8 months ago

  • Status changed from New to Needs Feedback

Interesting, I got a similar finding with #100035, but my case didn't involve translations. Do you mind checking whether my bugfix was incomplete?

Actions #2

Updated by Sebastian Michaelsen 8 months ago

@Andreas Kienast Thank you very much for the pointer. It seems your fix is specific for a workspaces related field. I suppose also in your case DataHandler still explicitly saves the inline records (given they have a visbility toggle available).

I checked on demo.typo3.org, which currently runs v12.4.5 and the saving request also features the hidden field:

Actions #3

Updated by Sebastian Michaelsen 8 months ago

  • Status changed from Needs Feedback to New
Actions #4

Updated by Patrick Schriner 8 months ago

DataHandler::compareFieldArrayWithCurrentAndUnset should throw theses "empty" field away, but a lot of (expensive) stuff happens before

Actions #5

Updated by Sebastian Michaelsen 8 months ago

Yes, I took a deeper look. The problem seems to be that before unchanged fields get filtered out, the DataMapProcessor already adds records that also need saving. So for my unchanged inline record, it still schedules all its translation records to be udpated.

https://github.com/TYPO3/typo3/blob/2aebe1eac32747b427725422a22d0c08d00ef5fd/typo3/sysext/core/Classes/DataHandling/DataHandler.php#L834 (from main branch currently 13.0.0-dev)

Actions

Also available in: Atom PDF