Issue Bug Closed

#85788Escaping behaviour changed in QueryBuilder

Timo Pfeffer 08/09/18, 09:49 updated 02/19/22, 12:44

Description

In 7.6 the code below works without any problems. In 8.7 the code below crashes, because the ordering gets escaped in other way, so that it is not possible to implement functions like this anymore.
To be more specific the setOrderings function with the input of orderByField causes the crash.

Code:

public function findByUids($uids){

    if(!isset($uids) || empty($uids)){
        return NULL;
    }

    $uidListString = $uids;
    if(!is_array($uids)){
        $uidListString = explode(',', $uids);
    }

    $query = $this->createQuery();
    $query->getQuerySettings()->setRespectStoragePage(FALSE);

    //here i set the orderings
    $orderings = $this->orderByField('uid', $uidListString);
    $query->setOrderings($orderings);

    $query->matching(
        $query->logicalAnd(
            $query->in('uid', $uidListString)
        )
    );

    return $query->execute();
}

/**
 * @param string $field
 * @param array $values
 *
 * @return array
 */
protected function orderByField($field, $values) {
    $orderings = array();
    foreach ($values as $value) {
        $orderings["$field={$value}"] =  \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING;
    }
    return $orderings;
}

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.