[TASK] Replace DatabaseConnection->cleanIntArray() 61/49361/4
authorBenni Mack <benni@typo3.org>
Wed, 3 Aug 2016 17:54:25 +0000 (19:54 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 3 Aug 2016 18:45:08 +0000 (20:45 +0200)
DatabaseConnection uses plain PHP code under the hood,
so the code can be used directly.

Resolves: #77392
Releases: master
Change-Id: I8b64414a538dc68cb4594751c393009c54b499c6
Reviewed-on: https://review.typo3.org/49361
Tested-by: Bamboo TYPO3com <info@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Form/Wizard/SuggestWizardDefaultReceiver.php
typo3/sysext/beuser/Classes/Domain/Repository/BackendUserRepository.php
typo3/sysext/core/Classes/DataHandling/PlainDataResolver.php
typo3/sysext/core/Classes/Database/RelationHandler.php
typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbQueryParserTest.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Classes/Page/PageRepository.php
typo3/sysext/indexed_search/Classes/Hook/CrawlerHook.php

index 6d5e31d..44d341b 100644 (file)
@@ -245,7 +245,7 @@ class SuggestWizardDefaultReceiver
             $this->queryBuilder->andWhere($expressionBuilder->orX($searchClause));
         }
         if (!empty($this->allowedPages)) {
-            $pidList = $GLOBALS['TYPO3_DB']->cleanIntArray($this->allowedPages);
+            $pidList = array_map('intval', $this->allowedPages);
             if (!empty($pidList)) {
                 $this->queryBuilder->andWhere(
                     $expressionBuilder->in('pid', $pidList)
@@ -276,7 +276,7 @@ class SuggestWizardDefaultReceiver
         // fetch all
         while ($depth - $level > 0 && !empty($pageIds)) {
             ++$level;
-            $pidList = $GLOBALS['TYPO3_DB']->cleanIntArray($pageIds);
+            $pidList = array_map('intval', $pageIds);
             $rows = $queryBuilder->where($queryBuilder->expr()->in('pid', $pidList))
                 ->execute()
                 ->fetchAll();
index a867ce6..fbe3ab1 100644 (file)
@@ -31,7 +31,7 @@ class BackendUserRepository extends \TYPO3\CMS\Extbase\Domain\Repository\Backend
     public function findByUidList(array $uidList)
     {
         $query = $this->createQuery();
-        return $query->matching($query->in('uid', $GLOBALS['TYPO3_DB']->cleanIntArray($uidList)))->execute();
+        return $query->matching($query->in('uid', array_map('intval', $uidList)))->execute();
     }
 
     /**
index 801e6d5..3fd1e12 100644 (file)
@@ -324,7 +324,7 @@ class PlainDataResolver
      */
     protected function intImplode($delimiter, array $values)
     {
-        return implode($delimiter, $this->getDatabaseConnection()->cleanIntArray($values));
+        return implode($delimiter, array_map('intval', $values));
     }
 
     /**
index 72e9e08..f632fcf 100644 (file)
@@ -1170,7 +1170,7 @@ class RelationHandler
      */
     protected function purgeVersionedIds($tableName, array $ids)
     {
-        $ids = $this->getDatabaseConnection()->cleanIntArray($ids);
+        $ids = array_map('intval', $ids);
         $ids = array_combine($ids, $ids);
 
         $versions = $this->getDatabaseConnection()->exec_SELECTgetRows(
@@ -1202,7 +1202,7 @@ class RelationHandler
      */
     protected function purgeLiveVersionedIds($tableName, array $ids)
     {
-        $ids = $this->getDatabaseConnection()->cleanIntArray($ids);
+        $ids = array_map('intval', $ids);
         $ids = array_combine($ids, $ids);
 
         $versions = $this->getDatabaseConnection()->exec_SELECTgetRows(
@@ -1235,7 +1235,7 @@ class RelationHandler
      */
     protected function purgeDeletePlaceholder($tableName, array $ids)
     {
-        $ids = $this->getDatabaseConnection()->cleanIntArray($ids);
+        $ids = array_map('intval', $ids);
         $ids = array_combine($ids, $ids);
 
         $versions = $this->getDatabaseConnection()->exec_SELECTgetRows(
index 9b88409..7a8ef03 100644 (file)
@@ -784,7 +784,8 @@ class Typo3DbQueryParser implements \TYPO3\CMS\Core\SingletonInterface
                 default:
                     return '';
             }
-            $pageIdStatement = $tableAlias . '.pid IN (' . implode(',', $this->databaseHandle->cleanIntArray($storagePageIds)) . ')';
+            $storagePageIds = array_map('intval', $storagePageIds);
+            $pageIdStatement = $tableAlias . '.pid IN (' . implode(',', $storagePageIds) . ')';
         }
         return $pageIdStatement;
     }
index 5dbcfda..fda0576 100644 (file)
@@ -489,7 +489,6 @@ class Typo3DbQueryParserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         $mockTypo3DbQueryParser = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::class, array('dummy'), array(), '', false);
         $mockFrontendVariableCache = $this->createMock(\TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class);
         $mockDatabaseHandle = $this->prophesize(DatabaseConnection::class);
-        $mockDatabaseHandle->cleanIntArray(Argument::cetera())->willReturnArgument(0);
         $mockTypo3DbQueryParser->_set('databaseHandle', $mockDatabaseHandle->reveal());
         $mockTypo3DbQueryParser->_set('tableColumnCache', $mockFrontendVariableCache);
         $mockFrontendVariableCache->expects($this->once())->method('get')->will($this->returnValue(array('pid' => '42')));
index 738e52b..0bbf81a 100644 (file)
@@ -7601,7 +7601,7 @@ class ContentObjectRenderer
             if (count($listArr) === 1) {
                 $comparison = '=' . (int)$listArr[0];
             } else {
-                $comparison = ' IN (' . implode(',', $this->getDatabaseConnection()->cleanIntArray($listArr)) . ')';
+                $comparison = ' IN (' . implode(',', $listArr) . ')';
             }
             // If move placeholder shall be considered, select via t3ver_move_id
             if ($considerMovePlaceholders) {
index 454f958..c949f11 100644 (file)
@@ -405,7 +405,7 @@ class PageRepository
                 $res = $db->exec_SELECTquery(
                     implode(',', $fieldArr),
                     'pages_language_overlay',
-                    'pid IN(' . implode(',', $db->cleanIntArray($page_ids)) . ')'
+                    'pid IN(' . implode(',', array_map('intval', $page_ids)) . ')'
                     . ' AND sys_language_uid=' . (int)$lUid . $this->enableFields('pages_language_overlay')
                 );
                 $overlays = array();
@@ -608,7 +608,7 @@ class PageRepository
         $db = $this->getDatabaseConnection();
 
         $whereStatement = $relationField . ' IN ('
-            . implode(',', $db->cleanIntArray($pageIds)) . ')'
+            . implode(',', array_map('intval', $pageIds)) . ')'
             . $this->where_hid_del
             . $this->where_groupAccess
             . ' '
index e47534e..d3334a2 100644 (file)
@@ -667,7 +667,7 @@ class CrawlerHook
             foreach ($oldPhashRows as $pHashRow) {
                 $pHashesToDelete[] = $pHashRow['phash'];
             }
-            $where_clause = 'phash IN (' . implode(',', $GLOBALS['TYPO3_DB']->cleanIntArray($pHashesToDelete)) . ')';
+            $where_clause = 'phash IN (' . implode(',', array_map('intval', $pHashesToDelete)) . ')';
             $tables = array(
                 'index_debug',
                 'index_fulltext',