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 #1

Updated by Benni Mack over 6 years ago

  • Target version changed from 8.7.13 to 8.7.19
Actions #2

Updated by Susanne Moog about 6 years ago

  • Target version changed from 8.7.19 to Candidate for patchlevel
Actions #3

Updated by Gerrit Code Review over 5 years ago

  • Status changed from New to Under Review

Patch set 17 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/+/56530

Actions #4

Updated by Gerrit Code Review over 5 years ago

Patch set 18 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/+/56530

Actions #5

Updated by Gerrit Code Review over 5 years ago

Patch set 19 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/+/56530

Actions #6

Updated by Gerrit Code Review over 5 years ago

Patch set 20 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/+/56530

Actions #7

Updated by Gerrit Code Review about 5 years ago

Patch set 1 for branch 9.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/+/61609

Actions #8

Updated by Sascha Egerer about 5 years ago

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

Updated by Benni Mack almost 5 years ago

  • Status changed from Resolved to Closed
Actions #10

Updated by Gerrit Code Review over 3 years ago

  • Status changed from Closed to Under Review

Patch set 1 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68770

Actions #11

Updated by Tymoteusz Motylewski over 3 years ago

  • Status changed from Under Review to Closed
Actions

Also available in: Atom PDF