[!!!][TASK] Extbase: Remove preparsing of queries 70/49470/9
authorBenni Mack <benni@typo3.org>
Fri, 12 Aug 2016 16:06:46 +0000 (18:06 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 16 Aug 2016 11:07:31 +0000 (13:07 +0200)
The whole concept of having placeholders is a pseudo-prepared
statement idea, which RDBMS do inside their query cache. The logic
inside PHP is therefore removed.

The following public methods have been removed:
* Typo3DbBackend->quoteTextValueCallback()
* Typo3DbQueryParser->preparseQuery()
* Typo3DbQueryParser->normalizeParameterIdentifier()
* Typo3DbQueryParser->addDynamicQueryParts()
* ComparisonInterface->setParameterIdentifier
* ComparisonInterface->getParameterIdentifier

The following methods have been marked as deprecated:
* Comparison->setParameterIdentifier()
* Comparison->getParameterIdentifier()

This patch is one of the prerequisites to introduce the Doctrine DBAL
QueryBuilder instead of building raw SQL statements.

Resolves: #77502
Releases: master
Change-Id: Ia5be0148874c15337ab5ce60094e9eae72fe3d9e
Reviewed-on: https://review.typo3.org/49470
Tested-by: Bamboo TYPO3com <info@typo3.com>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Documentation/Changelog/master/Breaking-77502-ExtbasePreparsingOfQueriesRemoved.rst [new file with mode: 0644]
typo3/sysext/core/Documentation/Changelog/master/Deprecation-77502-ExtbasePreparsingOfQueriesRemoved.rst [new file with mode: 0644]
typo3/sysext/extbase/Classes/Persistence/Generic/Qom/Comparison.php
typo3/sysext/extbase/Classes/Persistence/Generic/Qom/ComparisonInterface.php
typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php
typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php
typo3/sysext/extbase/Tests/Functional/Persistence/QueryParserTest.php
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php

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 (file)
index 0000000..bdcfc97
--- /dev/null
@@ -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 (file)
index 0000000..dc841fd
--- /dev/null
@@ -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
index 72c68da..54f31c7 100644 (file)
@@ -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;
     }
 
index 58accba..ebd2050 100644 (file)
@@ -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();
 }
index 37e6afc..6d89958 100644 (file)
@@ -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'])) {
@@ -469,62 +469,6 @@ class Typo3DbBackend implements BackendInterface, SingletonInterface
     }
 
     /**
-     * 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
      *
      * @param AbstractValueObject $object The Value Object
index 03562c9..274f807 100644 (file)
@@ -87,108 +87,6 @@ class Typo3DbQueryParser implements \TYPO3\CMS\Core\SingletonInterface
     }
 
     /**
-     * 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.
      *
      * @param QueryInterface $query The query
@@ -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;
     }
index 562308c..eac68cc 100644 (file)
@@ -19,11 +19,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
      */
     protected $testExtensionsToLoad = array('typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example');
@@ -57,85 +52,12 @@ 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
-     */
     public function queryWithMultipleRelationsToIdenticalTablesReturnsExpectedResultForOrQuery()
     {
         /** @var \ExtbaseTeam\BlogExample\Domain\Repository\PostRepository $postRepository */
index a961bf4..68ffcef 100644 (file)
@@ -173,35 +173,6 @@ class Typo3DbBackendTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     }
 
     /**
-     * @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());
     }
 }