[TASK] Doctrine: Migrate escapeStrForLike() 23/49523/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Sun, 21 Aug 2016 14:39:17 +0000 (16:39 +0200)
committerBenni Mack <benni@typo3.org>
Sun, 21 Aug 2016 15:13:06 +0000 (17:13 +0200)
Change-Id: I512fd11f9ee0aa43c568b37cb0d30041aaba22c2
Resolves: #77560
Releases: master
Reviewed-on: https://review.typo3.org/49523
Tested-by: Bamboo TYPO3com <info@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/beuser/Classes/Domain/Repository/BackendUserRepository.php
typo3/sysext/fluid_styled_content/Classes/ViewHelpers/Menu/KeywordsViewHelper.php

index fbe3ab1..5b983f2 100644 (file)
@@ -50,9 +50,10 @@ class BackendUserRepository extends \TYPO3\CMS\Extbase\Domain\Repository\Backend
         // Username
         if ($demand->getUserName() !== '') {
             $searchConstraints = array();
+            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users');
             foreach (array('userName', 'uid', 'realName') as $field) {
                 $searchConstraints[] = $query->like(
-                    $field, '%' . $GLOBALS['TYPO3_DB']->escapeStrForLike($demand->getUserName(), 'be_users') . '%'
+                    $field, '%' . $queryBuilder->escapeLikeWildcards($demand->getUserName()) . '%'
                 );
             }
             $constraints[] = $query->logicalOr($searchConstraints);
index 0faef79..c9d68df 100644 (file)
@@ -13,7 +13,9 @@ namespace TYPO3\CMS\FluidStyledContent\ViewHelpers\Menu;
  *
  * The TYPO3 project - inspiring people to share!
  */
-use TYPO3\CMS\Core\Database\DatabaseConnection;
+
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
  * A view helper which returns pages with one of the same keywords as the given pages
@@ -109,9 +111,9 @@ class KeywordsViewHelper extends AbstractMenuViewHelper
 
         $keywordConstraints = array();
         if ($filteredKeywords) {
-            $db = $this->getDatabaseConnection();
+            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
             foreach ($filteredKeywords as $keyword) {
-                $keyword = $db->fullQuoteStr('%' . $db->escapeStrForLike($keyword, 'pages') . '%', 'pages');
+                $keyword = $queryBuilder->quote('%' . $queryBuilder->escapeLikeWildcards($keyword) . '%');
                 $keywordConstraints[] = 'keywords LIKE ' . $keyword;
             }
             $constraints .= ' AND (' . implode(' OR ', $keywordConstraints) . ')';
@@ -152,12 +154,4 @@ class KeywordsViewHelper extends AbstractMenuViewHelper
 
         return array_filter(array_map('trim', $keywordList));
     }
-
-    /**
-     * @return DatabaseConnection
-     */
-    protected function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
 }