Project

General

Profile

Actions

Bug #85020

closed

QueryGenerator interprets string as date

Added by Ralph Brugger over 6 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
-
Start date:
2018-05-16
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.1
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Using the diect_mail Special Queries for recipients, we're getting strnage Queries:

Make Query:

pid equals 2192

results in;

SELECT `uid`, `pid`, `deleted` FROM `tt_address` WHERE (pid = '7017444703') AND (`tt_address`.`deleted` = 0)

so the pid-value form the form (2192) will be interpreted as a date / year:

16.05.2192 11:11:43

2192 is the year, the rest is the current date ...

Debugging in direct_mail:

$whereClause = $queryGenerator->getQuery($queryGenerator->queryConfig) . BackendUtility::deleteClause($table);
\TYPO3\CMS\Core\Utility\DebugUtility::debug($queryGenerator->queryConfig, 'queryConfig');
array(1 item)
   0 => array(5 items)
      operator => '' (0 chars)
      type => 'FIELD_pid' (9 chars)
      comparison => 6 (integer)
      inputValue => '2192' (4 chars)
      inputValue1 => NULL

\TYPO3\CMS\Core\Utility\DebugUtility::debug($whereClause, 'whereClause');        
' pid = '7017444089' AND `tt_address`.`deleted` = 0' (50 chars)

The value is 2192 (string) and the comparison is set to 6.

QueryGenerator.php
comparison
    // Type = text      offset = 0
    ...
    '6_' => 'equals',

So "6" should be the right value it's a string. But not a date.

QueryGenerator.php

    public function getQuery($queryConfig, $pad = '')
    {
        ...

        foreach ($queryConfig as $key => $conf) {
            // Convert ISO-8601 timestamp (string) into unix timestamp (int)
            if (strtotime($conf['inputValue'])) {
                $conf['inputValue'] = strtotime($conf['inputValue']);
                if ($conf['inputValue1'] && strtotime($conf['inputValue1'])) {
                    $conf['inputValue1'] = strtotime($conf['inputValue1']);
                }
            }

        ...

in QueryGenerator::getQuery it will be always tried to get a strtotime value from the input value.
It doesn't matter which comparison-value is set.

comparison
    // Type = text      offset = 0
    ...
    '6_' => 'equals',

    // Type = date,time  offset = 96
    '96_' => 'equals',
    '97_' => 'does not equal',
    '98_' => 'is greater than',
    '99_' => 'is less than',
    '100_' => 'is between',
    '101_' => 'is not between',
    '102_' => 'binary AND equals',
    '103_' => 'binary AND does not equal',
    '104_' => 'binary OR equals',
    '105_' => 'binary OR does not equal',

AFAIR strtotime should only be done when the comparison is for dateime types:
    if (intval($conf['comparison']) >= 96 && intval($conf['comparison']) <= 105){
        if (strtotime($conf['inputValue'])) {
            $conf['inputValue'] = strtotime($conf['inputValue']);
            if ($conf['inputValue1'] && strtotime($conf['inputValue1'])) {
                $conf['inputValue1'] = strtotime($conf['inputValue1']);
            }
        }
    }

?
Actions

Also available in: Atom PDF