Bug #80749

Scheduler does not work with ADOdb / SELECT_queryArray passes NULL instead of strings

Added by Dan Untenzu 11 months ago. Updated 9 months ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2017-04-07
Due date:
% Done:

100%

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

Description

Hey,

I'm using TYPO3 7.6.16 and PostgreSQL 9.6.2.

Whenever I execute a scheduler task I get an exception

Argument 1 passed to TYPO3\CMS\Dbal\Database\DatabaseConnection::_quoteGroupBy() must be of the type array, string given, called in /typo3_src-7.6.16/typo3/sysext/dbal/Classes/Database/DatabaseConnection.php on line 1876

The reason for this is that the scheduler does not pass all expected parameters to the database method.

»/typo3/sysext/scheduler/Classes/Scheduler.php« (fetchTask, line 269) does pass an array with SELECT, FROM, WHERE and LIMIT to the database method »exec_SELECT_queryArray«.

»/typo3/sysext/core/Classes/Database/DatabaseConnection.php« (queryArray, line 358) uses all possible array keys and passes them to the »exec_SELECTquery« method. If the previous method did not provide one of the keys then »NULL« will be passed instead. In PostgreSQL this will cause the exception shown above.

Solution 1: Pass all possible array keys / parameters in the original method. E.g.

            $queryArray = [
                'SELECT' => 'uid, serialized_task_object',
                'FROM' => 'tx_scheduler_task',
                'WHERE' => 'uid = ' . (int)$uid,
                'GROUPBY' => '',
                'ORDERBY' => '',
                'LIMIT' => 1
            ];

Solution 2: We saw, that this error occured several times before, e.g: #76991 Instead of fixing the origin it may be a good idea to fix the »exec_SELECT_queryArray« and make sure, that this one passes all optional keys with a least an empty string. This means, that the method has to check for the existance of the optional keys. E.g.

        $queryPartsFallback = [
            'GROUPBY' => '',
            'ORDERBY' => '',
            'LIMIT' => ''
        ];
        $queryParts = array_merge($queryPartsFallback, $queryParts);
        return $this->exec_SELECTquery($queryParts['SELECT'], $queryParts['FROM'], $queryParts['WHERE'], $queryParts['GROUPBY'], $queryParts['ORDERBY'], $queryParts['LIMIT']);

The bug appears in 7.6 and 6.2

Associated revisions

Revision e2c8ffe9 (diff)
Added by Dan Untenzu 9 months ago

[BUGFIX] DBAL: Assure all optional query array parameters are set

The method »exec_SELECT_queryArray« uses an incoming array and
passes all possible query array keys on to the »exec_SELECTquery« method.
If not all keys were set, then »NULL« is passed. It should pass an
empty string however.

To avoid exceptions thrown due to NULL values, the method
now provides a fallback for all optional array keys.

Resolves: #80749
Releases: 7.6
Change-Id: I8cad33503f752062f771a53bade1188b6351d56d
Reviewed-on: https://review.typo3.org/52386
Tested-by: TYPO3com <>
Reviewed-by: Jan Helke <>
Tested-by: Jan Helke <>
Reviewed-by: Christian Kuhn <>
Tested-by: Christian Kuhn <>

History

#1 Updated by Dan Untenzu 11 months ago

  • Description updated (diff)

#2 Updated by Gerrit Code Review 11 months ago

  • Status changed from New to Under Review

Patch set 1 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52386

#3 Updated by Gerrit Code Review 9 months ago

Patch set 2 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52386

#4 Updated by Gerrit Code Review 9 months ago

Patch set 3 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52386

#5 Updated by Dan Untenzu 9 months ago

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

Also available in: Atom PDF