Project

General

Profile

Actions

Bug #81019

closed

Query Builder: Error when ordering by DateTime fields

Added by Radu Mogos about 7 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Extbase
Target version:
Start date:
2017-04-26
Due date:
% Done:

100%

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

Description

Hello

I have an Extbase model with a DateTime "crdate" field, defined like this in the model.

/**
 * crdate
 *
 * @var \DateTime
 */
protected $crdate;

In it's repo I'm just trying to fetch all its models in a custom function, all this function does is return all the objects and sort them by the crdate field:

    public function getLatestJobs($limit = 0) {
        $query = $this->createQuery();
        $query->getQuerySettings()->setRespectStoragePage(FALSE);
        if ($limit) {
            $query->setLimit($limit);
        }
        $query->setOrderings(array('crdate' => QueryInterface::ORDER_DESCENDING));

        return $query->execute();
    }

This generates a TYPO3 exception in the frontend, as the compiled code does an htmlspecialchars call when fetching the date.
This is the error I get: "#1476107295: PHP Warning: htmlspecialchars() expects parameter 1 to be string, object given", and the compiled code which generates the error looks like this:

$arguments98 = array();
$arguments98['date'] = NULL;
$arguments98['format'] = '';
$arguments98['base'] = NULL;
$arguments98['format'] = 'Y-m-d';
$array100 = array (
);$arguments98['date'] = htmlspecialchars($renderingContext->getVariableProvider()->getByPath('job.crdate', $array100), ENT_QUOTES);

I'm assuming that $renderingContext->getVariableProvider()->getByPath('job.crdate', $array100) returns a DateTime object while htmlspecialchars deals only with strings, obviously.


Related issues 1 (1 open0 closed)

Related to TYPO3 Core - Bug #79473: Typo3DbQueryParser fails since Doctrine by comparing date fieldsNew2017-01-26

Actions
Actions #1

Updated by Georg Ringer about 7 years ago

  • Related to Bug #79473: Typo3DbQueryParser fails since Doctrine by comparing date fields added
Actions #2

Updated by Benni Mack about 7 years ago

  • Target version changed from 8 LTS to next-patchlevel
Actions #3

Updated by Gerrit Code Review almost 7 years ago

  • Status changed from New to Under Review

Patch set 12 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52802

Actions #4

Updated by Gerrit Code Review almost 7 years ago

Patch set 13 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52802

Actions #5

Updated by Gerrit Code Review almost 7 years ago

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/53244

Actions #6

Updated by Christian Toffolo almost 7 years ago

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

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF