Project

General

Profile

Actions

Bug #95921

closed

Array to string conversion error in ContentObjectRenderer (PHP8)

Added by Chris Müller about 3 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2021-11-09
Due date:
% Done:

100%

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

Description

With the following configuration of a DatabaseQueryProcessor:

10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
    table = tx_myext_table
    where = parent=###pages_uid### and parenttable="pages" 
    orderBy = sorting
    markers {
        pages_uid.field = uid
    }

    includeRecordsWithoutDefaultTranslation = 1
    as = records
}

The following error occurs:

PHP Warning: Array to string conversion in /var/www/html/public/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php line 6098

The problem here is that the orderBy part stored as an array:

[
    [
        'sorting',
        null
    ]
]

and used as $queryPartValue:

$queryPartValue = str_replace('###' . $marker . '###', $markerValue, $queryPartValue);

Actions #1

Updated by Torben Hansen almost 3 years ago

The "ugly hack" mentioned in the code seems to be non-functional. I debugged the code of the for-each loop and there also CompositeExpression objects are passed as argument to str_replace resulting in the objects being typecasted to strings. This results in useless $queryParts variable, since certain parts of the expression now are removed due to the typecast.

Best would be to check, if we either pass strings or one-dimensional arrays to str_replace, but actually, I'm pretty sure, that the whole for-each loop for the $queryParts variable is not required at all. To me it seems line 6121 to 6124 can be removed, since the $queryParts variable is not used afterwards.

Actions #2

Updated by Gerrit Code Review almost 3 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/+/72272

Actions #3

Updated by Gerrit Code Review almost 3 years 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/+/72260

Actions #4

Updated by Torben Hansen almost 3 years ago

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

Updated by Benni Mack about 2 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF