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 #1

Updated by Susanne Moog about 5 years ago

  • Category set to CLI
Actions #2

Updated by Gerrit Code Review about 4 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63940

Actions #3

Updated by Gerrit Code Review about 4 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63940

Actions #4

Updated by Gerrit Code Review about 4 years ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63907

Actions #5

Updated by Georg Ringer about 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #6

Updated by Benni Mack about 4 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF