Project

General

Profile

Actions

Feature #97639

closed

Multilang bug in cObjGetSingle. No data is returned for records if sys_language_uid is set to -1.

Added by JAKOTA Design Group GmbH over 2 years ago. Updated 10 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Content Rendering
Target version:
-
Start date:
2022-05-16
Due date:
% Done:

100%

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

Description

Request:

cObjGetSingle(
    'CONTENT', 
    [
         'table' => 'tx_extname_domain_model_brand',
        'select.' => [
          'pidInList' => '0',
          'uidInList' => '###brandUid###',
          'selectFields' => 'title',
          'markers.' => [
             'brandUid.' => [
                'data' => 'site:brand',
             ]
          ]
        ]
        'renderObj' => 'COA',
        'renderObj.' => [
          '10' => 'TEXT',
          '10.' => [
             'value' => '{field:title}',
             'insertData' => '1',
          ]
        ]
        'sanitize' => 1
    ]
)

If the record in tx_extname_domain_model_brand is sys_language_uid = 0 or has a translated record everything is fine.

But if the record has sys_language_uid = -1 and the page should be rendered in lang = 1, the marker is not filled.

As far as I can tell the bug is somewhere in

typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

Line 5888 public function getRecords

$statement = $this->exec_getQuery($tableName, $queryConfiguration);

Returns only the columnNames:

 protectedarray(4 items)
         0 => 'title' (5 chars)
         1 => 'uid' (3 chars)
         2 => 'pid' (3 chars)
         3 => 't3ver_state' (11 chars)

But should have also returned the column sys_language_uid.

Because of this missing column the next function call always returns null

$row = $tsfe->sys_page->getLanguageOverlay($tableName, $row);

public/typo3/sysext/core/Classes/Domain/Repository/PageRepository.php

Line 620

 && (int)$row[$tableControl['languageField']] !== -1

is not filled and always false.

As a workaround I added sys_language_uid to the selectFields

Working request:

cObjGetSingle(
    'CONTENT', 
    [
         'table' => 'tx_extname_domain_model_brand',
        'select.' => [
          'pidInList' => '0',
          'uidInList' => '###brandUid###',
          'selectFields' => 'title, sys_language_uid',
          'markers.' => [
             'brandUid.' => [
                'data' => 'site:brand',
             ]
          ]
        ]
        'renderObj' => 'COA',
        'renderObj.' => [
          '10' => 'TEXT',
          '10.' => [
             'value' => '{field:title}',
             'insertData' => '1',
          ]
        ]
        'sanitize' => 1
    ]
)


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #97710: Missing languagefield in select causes failing overlay Closed2022-05-31

Actions
Actions #1

Updated by Georg Ringer over 2 years ago

  • Description updated (diff)
Actions #2

Updated by Georg Ringer over 2 years ago

  • Status changed from New to Needs Feedback

can you test this with tt_content

I am using the following TS

page.39 = CONTENT
page.39 {
  stdWrap.wrap = here:
  table = tt_content
  select {
    pidInList = 61
    uidInList = 28,27
  }
  renderObj = TEXT
  renderObj {
    value = datensatz: {field:uid} ({field:sys_language_uid})
    insertData = 1
  }
}

which gives me: here:datensatz: 27 (-1)datensatz: 28 (0)

tested in latest master (12)

Actions #3

Updated by JAKOTA Design Group GmbH over 2 years ago

Hi,

Yes this also happens with tt_content, if you set selectFields.

Here is your example code:


contenttest = CONTENT
contenttest {
  stdWrap.wrap = here:
  table = tt_content
  select {
    pidInList = 26
    uidInList = 12614
    selectFields = header
  }
  renderObj = TEXT
  renderObj {
    value = datensatz: {field:header} {field:uid} ({field:sys_language_uid})
    insertData = 1
  }
}

If I have the element 12614 in lang 0 and translated to 1 it works as expected.
But if 12614 only exists as -1 (all lang) version and the page is rendered in lang 1 the output look like this

Extbase Variable Dump
'here:' (5 chars)

And as soon as I add sys_language_uid to the selected fields


contenttest = CONTENT
contenttest {
  stdWrap.wrap = here:
  table = tt_content
  select {
    pidInList = 26
    uidInList = 12614
    selectFields = header,sys_language_uid
  }
  renderObj = TEXT
  renderObj {
    value = datensatz: {field:header} {field:uid} ({field:sys_language_uid})
    insertData = 1
  }
}

it is working again

Extbase Variable Dump
'here:datensatz: TEST TEST TEST 12614 (-1)' (41 chars)

So my guess is that the lang id field (if set in the TCA) should always be returned like uid, pid and t3ver_state is.
Or this behaviour should be documented.

Actions #4

Updated by JAKOTA Design Group GmbH over 2 years ago

Hmmmm I guess, never mind....

I was just blind
https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/Functions/Select.html#selectfields

But still, this behaviour is strange. But it seems by design.

Actions #5

Updated by Riccardo De Contardi about 2 years ago

@JAKOTA Design Group GmbH thank you for your answer and sorry for this late reply.

Do you think that there is still something to do here, or can I close this issue? Should it be turned into a feature?

Thank you

Actions #6

Updated by JAKOTA Design Group GmbH about 2 years ago

  • Tracker changed from Bug to Feature
  • TYPO3 Version deleted (11)

Hi, as I said it is inconsistent that some fields that are needed by the core (like uid or pid) are added to the selected fields by default and others like the sys_language_uid are not.

And that leads to other issues like: https://forge.typo3.org/issues/97710

But as this is documented and as of now a behaviour by design, I'd like this to change from bug report to a feature request.

Which would also fix the issue 97710.

Thanks

Actions #7

Updated by Simon Schaufelberger about 2 years ago

  • Description updated (diff)
Actions #8

Updated by Gerrit Code Review over 1 year ago

  • Status changed from Needs Feedback to Under Review

Patch set 5 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/+/74796

Actions #9

Updated by JAKOTA Design Group GmbH over 1 year ago

  • Related to Bug #97710: Missing languagefield in select causes failing overlay added
Actions #10

Updated by Gerrit Code Review over 1 year ago

Patch set 6 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/+/74796

Actions #11

Updated by Gerrit Code Review over 1 year ago

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

Actions #12

Updated by Gerrit Code Review over 1 year ago

Patch set 8 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/+/74796

Actions #13

Updated by Gerrit Code Review over 1 year ago

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

Actions #14

Updated by Gerrit Code Review over 1 year ago

Patch set 1 for branch 11.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/+/79779

Actions #15

Updated by Henrik Elsner over 1 year ago

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

Updated by Benni Mack 10 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF