Feature #93450

ContentObjectRenderer: allow TypoScript select object without any constraint of uidInList or pidInList

Added by Ayke Halder 10 months ago. Updated 5 days ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
Content Rendering
Target version:
-
Start date:
2021-02-05
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

Current state

A TypoScript select object must have at least one constraint of uid or pid - configured via properties uidInList and pidInList

Feature proposal

Allow to completely disable the pid_uid constraint on purpose in ContentObjectRenderer.

10 = CONTENT
10 {
   table =
   select {
      uidInList = 0
      pidInList = 0
   }
}

Motivation

Get records from a m:n-relation where you already know the uids of one side.
Tables respresenting m:n-relations do not have a field named uid - instead they have uid_local and uid_foreign.

As a current work-around you must pre-fill pidInList with all pids of the entire database to make this work:

pidInList.data = leveluid : 0
recursive = 99

Example code taken from tt_content.menu_categorized_content

tt_content.menu_categorized_content =< lib.contentElement
tt_content.menu_categorized_content {
    templateName = MenuCategorizedContent
    dataProcessing {
        10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
        10 {
            table = tt_content
            selectFields = tt_content.*
            groupBy = uid
            pidInList.data = leveluid : 0
            recursive = 99
            join.data = field:selected_categories
            join.wrap = sys_category_record_mm ON uid = sys_category_record_mm.uid_foreign AND sys_category_record_mm.uid_local IN(|)
            where.data = field:category_field
            where.wrap = tablenames='tt_content' and fieldname='|'
            orderBy = tt_content.sorting
            as = content
        }
    }
}

Code base

TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer - L6078-L6081

        // If not uid and not pid then uid is set to 0 - which results in nothing!!
        if (!$pid_uid_flag) {
            $constraints[] = $expressionBuilder->eq($table . '.uid', 0);
        }

Related issues

Related to TYPO3 Core - Feature #87551: Explicitly allow ignoring "pidInList" in TS select functionNewAndreas Wolf

Actions
Related to TYPO3 Core - Bug #91718: DatabaseQueryProcessor should find tt_content entries by uid regradless the pidNew2020-06-26

Actions
#1

Updated by Ayke Halder 10 months ago

  • Related to Feature #87551: Explicitly allow ignoring "pidInList" in TS select function added
#3

Updated by Ayke Halder 10 months ago

  • Description updated (diff)
#4

Updated by Joerg Kummer 10 months ago

  • Related to Bug #91718: DatabaseQueryProcessor should find tt_content entries by uid regradless the pid added
#5

Updated by Gerrit Code Review 10 months 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/+/67912

#6

Updated by Gerrit Code Review 9 months 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/+/67912

#7

Updated by Gerrit Code Review 9 months ago

Patch set 3 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/+/67912

#8

Updated by Jonas Schwabe 5 months ago

I have applied that patch a few days ago because I had the same issue when using a where clause for a record I was not able to reference by uid.

The issue I have been seeing since then: When you have a record that optionally references to something else. When the reference is not filled and an int field is being used the value that is being passed to uidInList is actually 0 and the programmer would not expect that every entry is being fetched from the table.

In our case a random entry was displayed where none was fetched before this patch was applied and field_in_tt_content is 0.

90 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
90 {
  as = fluidVariable
  table = the_table
  uidInList.field = field_in_tt_content
  pidInList = 0
}

So I'd probably switch to custom logic here and not use DatabaseQueryProcessor if I don't have a uid or pid that should be listed so existing code doe snot stop working as expected.

#9

Updated by Gerrit Code Review 5 days ago

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

Also available in: Atom PDF