Project

General

Profile

Actions

Bug #78257

closed

dbal class DatabaseConnection tries to explode array (TYPO3 7.6 and 6.2)

Added by M. Ecker over 7 years ago. Updated over 6 years ago.

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

0%

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

Description

Situation:
An extbase extension connects to an external postgres database (as additional database, which is also accessed by other systems) with models 'person', 'organisationUnit' and 'affiliation' (which contains each one person, one organisationUnit and other properties). Invoking the listAction for affiliation within a backend module causes

Uncaught TYPO3 Exception
#1: PHP Warning: explode() expects parameter 2 to be string, array given in /var/www/typo3_src-7.6.11/typo3/sysext/dbal/Classes/Database/DatabaseConnection.php line 3673

Existing code (line 3670ff.):

// do we have a field name in the value?
// this is a very simplistic check, beware
if (!is_numeric($sqlPartArray[$k]['value'][0]) && !isset($sqlPartArray[$k]['value'][1])) {
                        $fieldArray = explode('.', $sqlPartArray[$k]['value'][0]);
...
}

Analysis:
If the query was built by extbase to get a subentity (the person of an affiliation), $sqlPartArray[$k]['value']0 will contain the array structure this code is expecting to be found at $sqlPartArray[$k]['value'] - so it's neither numeric nor a $sqlPartArray[$k]['value']1 exists.

A very simple patch would be to add an additional condition in line 3672:

if (!is_numeric($sqlPartArray[$k]['value'][0]) && !is_array($sqlPartArray[$k]['value'][0]) && !isset($sqlPartArray[$k]['value'][1])) 
{...}

As far as I can see this seems to work without any side effects, while changing the array $sqlPartArray[$k]['value'] would cause side effects.

In TYPO3 6.2 the code is the same, the line number is 3553.

Actions

Also available in: Atom PDF