Project

General

Profile

Actions

Bug #87777

closed

OrphanRecordsCommand is counting wrong

Added by Stefan P about 5 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
CLI
Target version:
-
Start date:
2019-02-25
Due date:
% Done:

100%

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

Description

The whole runtime logic of the OrphanRecordsCommand is very strange.

It loops over every TCA-registered table, but in the loop it initialises $totalOrphans = 0, this does not make sense at all. The output about how many are found is made after every table, but it mixes per-table and total statistics and it does not display the table name. Because of this, I just got this full output:

! [NOTE] Found 34 records in 1 database tables.
! [NOTE] Found 7 records in 2 database tables.
! [NOTE] Found 32 records in 3 database tables.

The first number in the line is the number of orphaned records in the current table, the second number is the total number of tables that had orphaned records. I'd expect an output like this instead:

! [NOTE] Found 34 records in tx_mytable_1.
! [NOTE] Found 7 records in tx_mytable_2.
! [NOTE] Found 32 records in tx_mytable_3.
! [NOTE] Done searching. Found a total of 73 records in 3 tables.

I'd also suggest just calling the delete method in the loop (if not dry-run), instead of first collecting everything and then deleting everything. Pseudo code: foreach tables as table { find orphans of table; delete orphans or table; }. This should lower the memory and execution time footprint (on my database the current logic takes around 20 minutes to just find the records, but after all the command just uses simple SQL selects on indexed columns, these shouldn't take so long).

Actions

Also available in: Atom PDF