Project

General

Profile

Actions

Bug #102355

closed

Extbase resolves all 1:n relations even though count indicates no releations

Added by Alexander Schnitzler over 1 year ago. Updated 2 months ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2023-11-09
Due date:
% Done:

0%

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

Description

Extbases DataMapper resolves relations to other entities. 1:n relations usually store a relation count on the parent, so whenever it shows 0, it wouldn't be necessary to try to fetch relations. This saves 1 query per relation but in certain scenarios with many entities and relations this saves tons of superfluous db operations.

protected function fetchRelatedEager(DomainObjectInterface $parentObject, $propertyName, $fieldValue = '')
{
    return $fieldValue === '' ? $this->getEmptyRelationValue($parentObject, $propertyName) : $this->getNonEmptyRelationValue($parentObject, $propertyName, $fieldValue);
}

This method already tries to be smart but it only sees empty strings as empty relation value.

Proposal: Expect the $fieldValue to hold an integer, cast other types to int and evaluate if said int is 0. https://3v4l.org/mqsvQ

Actions #1

Updated by Christian Kuhn 2 months ago

  • Status changed from New to Rejected

Hey. I'm going to reject here: I have a quite strong opinion that we need to get rid of the "parent count" fields altogether: they are notoriously outdated and they have logic collisions in workspace scenarios where they can never have the 'correct' value. I worked a lot on sys_refindex in recent versions: this one allows to fetch relations of multiple rows and fields with one query, and we're starting to actively use it in the frontend since v13, and it has good test coverage, so it would be a possible solution switching to this instead.

Actions

Also available in: Atom PDF