Issue Bug Closed

#72850foreach error in DatabaseTreeDataProvider

Franz Holzinger 01/20/16, 21:04 updated 10/02/18, 11:20

Description

The foreach loop in /typo3_src-7.6.2/typo3/sysext/core/Classes/Tree/TableConfiguration/DatabaseTreeDataProvider.php raises a PHP error when no record has been found.

Add the check if not empty.

    protected function listFieldQuery($fieldName, $queryId)
    {
        $records = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', $this->getTableName(), $GLOBALS['TYPO3_DB']->listQuery($fieldName, (int)$queryId, $this->getTableName()) . ((int)$queryId === 0 ? ' OR CAST(' . $fieldName . ' AS CHAR) = \'\'' : ''));
        $uidArray = array();
        if (!empty($records)) {
            foreach ($records as $record) {
                $uidArray[] = $record['uid'];
            }
        }
        return $uidArray;
    }

Reviews 2