diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-77502-ExtbasePreparsingOfQueriesRemoved.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-77502-ExtbasePreparsingOfQueriesRemoved.rst new file mode 100644 index 0000000000000000000000000000000000000000..bdcfc971e628b84debc43c111af0cb104a8d7e23 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Breaking-77502-ExtbasePreparsingOfQueriesRemoved.rst @@ -0,0 +1,35 @@ +========================================================= +Breaking: #77502 - Extbase: Preparsing of queries removed +========================================================= + +Description +=========== + +Extbase's custom implementation to pre-parse and cache queries has been removed in favor of using the RDBMS' native implementation +via Doctrine DBAL. + +The following public methods have been removed: +* Typo3DbBackend->quoteTextValueCallback() +* Typo3DbQueryParser->preparseQuery() +* Typo3DbQueryParser->normalizeParameterIdentifier() +* Typo3DbQueryParser->addDynamicQueryParts() +* ComparisonInterface->setParameterIdentifier +* ComparisonInterface->getParameterIdentifier + + +Impact +====== + +Calling any of the methods above will result in a fatal PHP error. + + +Affected Installations +====================== + +Any TYPO3 installation using custom logic inside Extbase's own Persistence layer within ``Typo3DbBackend`` or ``Typo3DbQueryParser``. + + +Migration +========= + +Remove the functionality and just use ``Typo3DbQueryParser->parseQuery``. \ No newline at end of file diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-77502-ExtbasePreparsingOfQueriesRemoved.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-77502-ExtbasePreparsingOfQueriesRemoved.rst new file mode 100644 index 0000000000000000000000000000000000000000..dc841fd0f955ba185ecf9bbcad84f1e7fe974a86 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-77502-ExtbasePreparsingOfQueriesRemoved.rst @@ -0,0 +1,30 @@ +============================================================ +Deprecation: #77502 - Extbase: Preparsing of queries removed +============================================================ + +Description +=========== + +The following methods and properties within Extbase's persistence query comparison interface have been marked as deprecated: + +* Comparison->setParameterIdentifier() +* Comparison->getParameterIdentifier() + + +Impact +====== + +Calling any of the methods above will trigger a deprecation log entry. + + +Affected Installations +====================== + +Any TYPO3 installation using custom logic inside Extbase's own Persistence layer with parameters and placeholders within +``Typo3DbBackend`` or ``Typo3DbQueryParser`` and actively overwriting parameter identifiers within Extbase. + + +Migration +========= + +The methods can be removed by simply using the ``DataMapper->getPlainValue()`` functionality. \ No newline at end of file diff --git a/typo3/sysext/extbase/Classes/Persistence/Generic/Qom/Comparison.php b/typo3/sysext/extbase/Classes/Persistence/Generic/Qom/Comparison.php index 72c68da7a32c01a22acc5e6ec2b67d6dfc9398a8..54f31c70d01cdce41edfb3e6fd384c76284d27a9 100644 --- a/typo3/sysext/extbase/Classes/Persistence/Generic/Qom/Comparison.php +++ b/typo3/sysext/extbase/Classes/Persistence/Generic/Qom/Comparison.php @@ -14,6 +14,7 @@ namespace TYPO3\CMS\Extbase\Persistence\Generic\Qom; * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Persistence\QueryInterface; /** @@ -78,6 +79,7 @@ class Comparison implements ComparisonInterface /** * @var string + * @deprecated since TYPO3 v8, will be removed in TYPO3 v9 */ protected $parameterIdentifier; @@ -138,17 +140,21 @@ class Comparison implements ComparisonInterface /** * @param string $parameterIdentifier * @return void + * @deprecated since TYPO3 v8, will be removed in TYPO3 v9 */ public function setParameterIdentifier($parameterIdentifier) { + GeneralUtility::logDeprecatedFunction(); $this->parameterIdentifier = $parameterIdentifier; } /** * @return string + * @deprecated since TYPO3 v8, will be removed in TYPO3 v9 */ public function getParameterIdentifier() { + GeneralUtility::logDeprecatedFunction(); return $this->parameterIdentifier; } diff --git a/typo3/sysext/extbase/Classes/Persistence/Generic/Qom/ComparisonInterface.php b/typo3/sysext/extbase/Classes/Persistence/Generic/Qom/ComparisonInterface.php index 58accba06142e331429199de1566690ca4c75e5e..ebd20504afacc67606ee4953392e6e98d1eb4d05 100644 --- a/typo3/sysext/extbase/Classes/Persistence/Generic/Qom/ComparisonInterface.php +++ b/typo3/sysext/extbase/Classes/Persistence/Generic/Qom/ComparisonInterface.php @@ -81,15 +81,4 @@ interface ComparisonInterface extends ConstraintInterface * @return StaticOperandInterface the operand; non-null */ public function getOperand2(); - - /** - * @param string $parameterIdentifier - * @return void - */ - public function setParameterIdentifier($parameterIdentifier); - - /** - * @return string - */ - public function getParameterIdentifier(); } diff --git a/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php b/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php index 37e6afcde77ac317099e154016a994ee075f6093..6d89958c2dd103196aa2b6afe561b31e6ac8750f 100644 --- a/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php +++ b/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php @@ -337,7 +337,7 @@ class Typo3DbBackend implements BackendInterface, SingletonInterface if ($statement instanceof Qom\Statement) { $rows = $this->getObjectDataByRawQuery($statement); } else { - $statementParts = $this->getStatementParts($query); + $statementParts = $this->queryParser->parseQuery($query); $rows = $this->getRowsFromDatabase($statementParts); } @@ -442,7 +442,7 @@ class Typo3DbBackend implements BackendInterface, SingletonInterface throw new \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Exception\BadConstraintException('Could not execute count on queries with a constraint of type TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\Statement', 1256661045); } - $statementParts = $this->getStatementParts($query); + $statementParts = $this->queryParser->parseQuery($query); $fields = '*'; if (isset($statementParts['keywords']['distinct'])) { @@ -468,62 +468,6 @@ class Typo3DbBackend implements BackendInterface, SingletonInterface return (int)max(0, $count); } - /** - * Build the query statement parts as SQL - * - * @param QueryInterface $query - * @return array - * @throws \RuntimeException - */ - protected function getStatementParts($query) - { - list($_, $parameters) = $this->queryParser->preparseQuery($query); - $statementParts = $this->queryParser->parseQuery($query); - - if (!$statementParts) { - throw new \RuntimeException('Your query could not be built.', 1394453197); - } - - $this->queryParser->addDynamicQueryParts($query->getQuerySettings(), $statementParts); - - // Limit and offset are not cached to allow caching of pagebrowser queries. - $statementParts['limit'] = ((int)$query->getLimit() ?: null); - $statementParts['offset'] = ((int)$query->getOffset() ?: null); - - return $this->resolveParameterPlaceholders($statementParts, $parameters); - } - - /** - * Replaces the parameters in the queryStructure with given values - * - * @param array $statementParts - * @param array $parameters - * @return array - */ - protected function resolveParameterPlaceholders(array $statementParts, array $parameters) - { - $tableName = reset($statementParts['tables']) ?: 'foo'; - - foreach ($parameters as $parameterPlaceholder => $parameter) { - $parameter = $this->dataMapper->getPlainValue($parameter, null, array($this, 'quoteTextValueCallback'), array('tablename' => $tableName)); - $statementParts['where'] = str_replace($parameterPlaceholder, $parameter, $statementParts['where']); - } - - return $statementParts; - } - - /** - * Will be called by the data mapper to quote string values. - * - * @param string $value The value to be quoted. - * @param array $parameters Additional parameters array currently containing the "tablename" key. - * @return string The quoted string. - */ - public function quoteTextValueCallback($value, $parameters) - { - return $this->databaseHandle->fullQuoteStr($value, $parameters['tablename']); - } - /** * Checks if a Value Object equal to the given Object exists in the database * diff --git a/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php b/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php index 03562c9efc3138a44e4fc40b9f6099d36b5c8847..274f807f703db58facc1373c671014ab18ee071b 100644 --- a/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php +++ b/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php @@ -86,108 +86,6 @@ class Typo3DbQueryParser implements \TYPO3\CMS\Core\SingletonInterface $this->databaseHandle = $GLOBALS['TYPO3_DB']; } - /** - * Preparses the query and returns the query's hash and the parameters - * - * @param QueryInterface $query The query - * @return array the hash and the parameters - */ - public function preparseQuery(QueryInterface $query) - { - list($parameters, $operators) = $this->preparseComparison($query->getConstraint()); - $hashPartials = array( - $query->getQuerySettings(), - $query->getSource(), - array_keys($parameters), - $operators, - $query->getOrderings(), - ); - $hash = md5(serialize($hashPartials)); - - return array($hash, $parameters); - } - - /** - * Walks through the qom's constraints and extracts the properties and values. - * - * In the qom the query structure and values are glued together. This walks through the - * qom and only extracts the parts necessary for generating the hash and filling the - * statement. It leaves out the actual statement generation, as it is the most time - * consuming. - * - * @param Qom\ConstraintInterface $comparison The constraint. Could be And-, Or-, Not- or ComparisonInterface - * @param string $qomPath current position of the child in the qom - * @return array Array of parameters and operators - * @throws \Exception - */ - protected function preparseComparison($comparison, $qomPath = '') - { - $parameters = array(); - $operators = array(); - $objectsToParse = array(); - - $delimiter = ''; - if ($comparison instanceof Qom\AndInterface) { - $delimiter = 'AND'; - $objectsToParse = array($comparison->getConstraint1(), $comparison->getConstraint2()); - } elseif ($comparison instanceof Qom\OrInterface) { - $delimiter = 'OR'; - $objectsToParse = array($comparison->getConstraint1(), $comparison->getConstraint2()); - } elseif ($comparison instanceof Qom\NotInterface) { - $delimiter = 'NOT'; - $objectsToParse = array($comparison->getConstraint()); - } elseif ($comparison instanceof Qom\ComparisonInterface) { - $operand1 = $comparison->getOperand1(); - $parameterIdentifier = $this->normalizeParameterIdentifier($qomPath . $operand1->getPropertyName()); - $comparison->setParameterIdentifier($parameterIdentifier); - $operator = $comparison->getOperator(); - $operand2 = $comparison->getOperand2(); - if ($operator === QueryInterface::OPERATOR_IN) { - $items = array(); - foreach ($operand2 as $value) { - $value = $this->dataMapper->getPlainValue($value); - if ($value !== null) { - $items[] = $value; - } - } - $parameters[$parameterIdentifier] = $items; - } else { - $parameters[$parameterIdentifier] = $operand2; - } - $operators[] = $operator; - } elseif (!is_object($comparison)) { - $parameters = array(array(), $comparison); - return array($parameters, $operators); - } else { - throw new \Exception('Can not hash Query Component "' . get_class($comparison) . '".', 1392840462); - } - - $childObjectIterator = 0; - foreach ($objectsToParse as $objectToParse) { - list($preparsedParameters, $preparsedOperators) = $this->preparseComparison($objectToParse, $qomPath . $delimiter . $childObjectIterator++); - if (!empty($preparsedParameters)) { - $parameters = array_merge($parameters, $preparsedParameters); - } - if (!empty($preparsedOperators)) { - $operators = array_merge($operators, $preparsedOperators); - } - } - - return array($parameters, $operators); - } - - /** - * normalizes the parameter's identifier - * - * @param string $identifier - * @return string - * @todo come on, clean up that method! - */ - public function normalizeParameterIdentifier($identifier) - { - return ':' . preg_replace('/[^A-Za-z0-9]/', '', $identifier); - } - /** * Parses the query and returns the SQL statement parts. * @@ -221,30 +119,15 @@ class Typo3DbQueryParser implements \TYPO3\CMS\Core\SingletonInterface } } - return $sql; - } - - /** - * Add query parts that MUST NOT be cached. - * Call this function for any query - * - * @param QuerySettingsInterface $querySettings - * @param array $sql - * @throws \InvalidArgumentException - * @return void - */ - public function addDynamicQueryParts(QuerySettingsInterface $querySettings, array &$sql) - { - if (!isset($sql['additionalWhereClause'])) { - throw new \InvalidArgumentException('Invalid statement given.', 1399512421); - } foreach ($sql['tableAliasMap'] as $tableAlias => $tableName) { - $statement = $this->getVisibilityConstraintStatement($querySettings, $tableName, $tableAlias); + $statement = $this->getVisibilityConstraintStatement($query->getQuerySettings(), $tableName, $tableAlias); if ($statement !== '') { $statement = $this->addNullConditionToStatementIfRequired($sql, $statement, $tableAlias); $sql['additionalWhereClause'][] = $statement; } } + + return $sql; } /** @@ -374,17 +257,14 @@ class Typo3DbQueryParser implements \TYPO3\CMS\Core\SingletonInterface */ protected function parseComparison(Qom\ComparisonInterface $comparison, Qom\SourceInterface $source, array &$sql) { - $parameterIdentifier = $this->normalizeParameterIdentifier($comparison->getParameterIdentifier()); - $operator = $comparison->getOperator(); $operand2 = $comparison->getOperand2(); if ($operator === QueryInterface::OPERATOR_IN) { $hasValue = false; foreach ($operand2 as $value) { - $value = $this->dataMapper->getPlainValue($value); - if ($value !== null) { - $parameters[] = $value; + if ($this->dataMapper->getPlainValue($value) !== null) { $hasValue = true; + break; } } if ($hasValue === false) { @@ -396,6 +276,7 @@ class Typo3DbQueryParser implements \TYPO3\CMS\Core\SingletonInterface if ($operand2 === null) { $sql['where'][] = '1<>1'; } else { + $value = $this->dataMapper->getPlainValue($operand2); if (!$source instanceof Qom\SelectorInterface) { throw new \RuntimeException('Source is not of type "SelectorInterface"', 1395362539); } @@ -414,14 +295,14 @@ class Typo3DbQueryParser implements \TYPO3\CMS\Core\SingletonInterface if ($typeOfRelation === ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY) { $relationTableName = $columnMap->getRelationTableName(); $additionalWhereForMatchFields = $this->getAdditionalMatchFieldsStatement($columnMap, $relationTableName, $relationTableName); - $sql['where'][] = $tableName . '.uid IN (SELECT ' . $columnMap->getParentKeyFieldName() . ' FROM ' . $relationTableName . ' WHERE ' . $columnMap->getChildKeyFieldName() . '=' . $parameterIdentifier . $additionalWhereForMatchFields . ')'; + $sql['where'][] = $tableName . '.uid IN (SELECT ' . $columnMap->getParentKeyFieldName() . ' FROM ' . $relationTableName . ' WHERE ' . $columnMap->getChildKeyFieldName() . '=' . $this->databaseHandle->fullQuoteStr($value, $relationTableName) . $additionalWhereForMatchFields . ')'; } elseif ($typeOfRelation === ColumnMap::RELATION_HAS_MANY) { $parentKeyFieldName = $columnMap->getParentKeyFieldName(); if (isset($parentKeyFieldName)) { $childTableName = $columnMap->getChildTableName(); - $sql['where'][] = $tableName . '.uid=(SELECT ' . $childTableName . '.' . $parentKeyFieldName . ' FROM ' . $childTableName . ' WHERE ' . $childTableName . '.uid=' . $parameterIdentifier . ')'; + $sql['where'][] = $tableName . '.uid=(SELECT ' . $childTableName . '.' . $parentKeyFieldName . ' FROM ' . $childTableName . ' WHERE ' . $childTableName . '.uid=' . $this->databaseHandle->fullQuoteStr($value, $childTableName) . ')'; } else { - $sql['where'][] = 'FIND_IN_SET(' . $parameterIdentifier . ', ' . $tableName . '.' . $columnName . ')'; + $sql['where'][] = 'FIND_IN_SET(' . $this->databaseHandle->fullQuoteStr($value, $tableName) . ', ' . $tableName . '.' . $columnName . ')'; } } else { throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException('Unsupported or non-existing property name "' . $propertyName . '" used in relation matching.', 1327065745); @@ -442,16 +323,28 @@ class Typo3DbQueryParser implements \TYPO3\CMS\Core\SingletonInterface */ protected function parseDynamicOperand(Qom\ComparisonInterface $comparison, Qom\SourceInterface $source, array &$sql) { + // workaround to find a suitable tablename + $tableName = reset($sql['tables']) ?: 'foo'; $operator = $this->resolveOperator($comparison->getOperator()); $operand = $comparison->getOperand1(); + $operand2 = $comparison->getOperand2(); $constraintSQL = $this->parseOperand($operand, $source, $sql) . ' ' . $operator . ' '; - - $parameterIdentifier = $this->normalizeParameterIdentifier($comparison->getParameterIdentifier()); - if ($operator === 'IN') { - $parameterIdentifier = '(' . $parameterIdentifier . ')'; + if ($comparison->getOperator() === QueryInterface::OPERATOR_IN) { + $constraintSQL .= '('; + $values = []; + foreach ($operand2 as $value) { + $values[] = $this->databaseHandle->fullQuoteStr($this->dataMapper->getPlainValue($value), $tableName); + } + $constraintSQL .= implode(',', $values); + $constraintSQL .= ')'; + } else { + if ($operand2 === null) { + $constraintSQL .= $this->dataMapper->getPlainValue($operand2); + } else { + $constraintSQL .= $this->databaseHandle->fullQuoteStr($this->dataMapper->getPlainValue($operand2), $tableName); + } } - $constraintSQL .= $parameterIdentifier; $sql['where'][] = $constraintSQL; } diff --git a/typo3/sysext/extbase/Tests/Functional/Persistence/QueryParserTest.php b/typo3/sysext/extbase/Tests/Functional/Persistence/QueryParserTest.php index 562308ce22a6773de3b9a5d2b555336c493cf072..eac68cc5fcb334a9d002a1e3be3c04992bfb9b38 100644 --- a/typo3/sysext/extbase/Tests/Functional/Persistence/QueryParserTest.php +++ b/typo3/sysext/extbase/Tests/Functional/Persistence/QueryParserTest.php @@ -18,11 +18,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; class QueryParserTest extends \TYPO3\CMS\Core\Tests\FunctionalTestCase { - /** - * @var \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser - */ - protected $queryParser; - /** * @var array */ @@ -57,82 +52,9 @@ class QueryParserTest extends \TYPO3\CMS\Core\Tests\FunctionalTestCase $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/post-tag-mm.xml'); $this->objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class); - $this->queryParser = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::class); $this->blogRepository = $this->objectManager->get(\ExtbaseTeam\BlogExample\Domain\Repository\BlogRepository::class); } - /** - * @test - */ - public function preparseQueryTakesOperatorsIntoHash() - { - $queryWithEquals = $this->blogRepository->createQuery(); - - $queryWithEquals->matching( - $queryWithEquals->equals('uid', 1) - ); - - list($hashWithEquals) = $this->queryParser->preparseQuery($queryWithEquals); - - $queryWithIn = $this->blogRepository->createQuery(); - - $queryWithIn->matching( - $queryWithIn->in('uid', array(1)) - ); - - list($hashWithIn) = $this->queryParser->preparseQuery($queryWithIn); - - $this->assertNotSame($hashWithEquals, $hashWithIn); - } - - /** - * @test - */ - public function preparseQueryHashDiffersForIsNullOperator() - { - $queryWithIsNull = $this->blogRepository->createQuery(); - - $queryWithIsNull->matching( - $queryWithIsNull->equals('title', null) - ); - - list($hashWithIsNull) = $this->queryParser->preparseQuery($queryWithIsNull); - - $queryWithoutIsNull = $this->blogRepository->createQuery(); - - $queryWithoutIsNull->matching( - $queryWithoutIsNull->equals('title', '') - ); - - list($hashWithoutIsNull) = $this->queryParser->preparseQuery($queryWithoutIsNull); - - $this->assertNotSame($hashWithIsNull, $hashWithoutIsNull); - } - - /** - * @test - */ - public function preparseQueryHashDiffersForEqualsCaseSensitiveArgument() - { - $queryCaseSensitiveFalse = $this->blogRepository->createQuery(); - - $queryCaseSensitiveFalse->matching( - $queryCaseSensitiveFalse->equals('title', 'PoSt1', false) - ); - - list($hashWithCaseSensitiveFalse) = $this->queryParser->preparseQuery($queryCaseSensitiveFalse); - - $queryCaseSensitiveTrue = $this->blogRepository->createQuery(); - - $queryCaseSensitiveTrue->matching( - $queryCaseSensitiveTrue->equals('title', 'PoSt1', true) - ); - - list($hashWithCaseSensitiveTrue) = $this->queryParser->preparseQuery($queryCaseSensitiveTrue); - - $this->assertNotSame($hashWithCaseSensitiveFalse, $hashWithCaseSensitiveTrue); - } - /** * @test */ diff --git a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php index a961bf44044286890e928a3e2b2c2ae16e4f17fe..68ffcef99a9ea718f6721d4c8cd07d3f3d78132d 100644 --- a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php @@ -172,35 +172,6 @@ class Typo3DbBackendTest extends \TYPO3\CMS\Core\Tests\UnitTestCase $this->assertSame(array($comparisonRow), $mockTypo3DbBackend->_call('doLanguageAndWorkspaceOverlay', $sourceMock, array($row), $mockQuerySettings, $workspaceUid)); } - /** - * @return array - */ - public function resolveParameterPlaceholdersReplacesValuesDataProvider() - { - return array( - 'string' => array('bar', '123', '123'), - 'array' => array('bar', array(1,2,3), '1,2,3'), - ); - } - - /** - * @param $parameter - * @param $value - * @param $expected - * @test - * @dataProvider resolveParameterPlaceholdersReplacesValuesDataProvider - */ - public function resolveParameterPlaceholdersReplacesValues($parameter, $value, $expected) - { - $mock = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::class, array('quoteTextValueCallback')); - $mock->expects($this->any())->method('quoteTextValueCallback')->will($this->returnArgument(0)); - $mock->_set('dataMapper', self::$dataMapper); - $stmtParts = array('tables' => array('foo'), 'where' => $parameter); - $parameters = array($parameter => $value); - $result = $mock->_call('resolveParameterPlaceholders', $stmtParts, $parameters); - $this->assertSame($expected, $result['where']); - } - /** * @test * @return void @@ -210,11 +181,9 @@ class Typo3DbBackendTest extends \TYPO3\CMS\Core\Tests\UnitTestCase $querySettingsProphecy = $this->prophesize(QuerySettingsInterface::class); $queryInterfaceProphecy = $this->prophesize(QueryInterface::class); $queryParserProphecy = $this->prophesize(Typo3DbQueryParser::class); - $queryParserProphecy->preparseQuery($queryInterfaceProphecy->reveal())->willReturn([123, []]); $queryParserProphecy->parseQuery($queryInterfaceProphecy->reveal())->willReturn( - ['tables' => ['tt_content']] + ['tables' => ['tt_content'], 'offset' => 10, 'limit' => null] ); - $queryParserProphecy->addDynamicQueryParts(\Prophecy\Argument::cetera())->willReturn(); $queryInterfaceProphecy->getQuerySettings()->willReturn($querySettingsProphecy->reveal()); $queryInterfaceProphecy->getConstraint()->willReturn(); $queryInterfaceProphecy->getLimit()->willReturn(); @@ -223,8 +192,8 @@ class Typo3DbBackendTest extends \TYPO3\CMS\Core\Tests\UnitTestCase $this->expectException(\InvalidArgumentException::class); $this->expectExceptionCode(1465223252); - $typo3DbQueryParser = new Typo3DbBackend(); - $typo3DbQueryParser->injectQueryParser($queryParserProphecy->reveal()); - $typo3DbQueryParser->getObjectCountByQuery($queryInterfaceProphecy->reveal()); + $typo3DbBackend = new Typo3DbBackend(); + $typo3DbBackend->injectQueryParser($queryParserProphecy->reveal()); + $typo3DbBackend->getObjectCountByQuery($queryInterfaceProphecy->reveal()); } }