[TASK] Doctrine: migrate ext:backend/avatar 27/47727/4
authorMichael Oehlhof <typo3@oehlhof.de>
Sat, 16 Apr 2016 09:58:52 +0000 (11:58 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 18 Apr 2016 23:00:30 +0000 (01:00 +0200)
Resolves: #75707
Releases: master
Change-Id: I98ebd90c10b40ee8233ec044ac9c4f2afae802a8
Reviewed-on: https://review.typo3.org/47727
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Backend/Avatar/DefaultAvatarProvider.php

index 8b3831a..a7551b7 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Backend\Backend\Avatar;
  * The TYPO3 project - inspiring people to share!
  */
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Database\Query\QueryBuilder;
 use TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException;
 use TYPO3\CMS\Core\Resource\ProcessedFile;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
@@ -65,21 +67,18 @@ class DefaultAvatarProvider implements AvatarProviderInterface
      */
     protected function getAvatarFileUid($beUserId)
     {
-        $file = $this->getDatabaseConnection()->exec_SELECTgetSingleRow(
-            'uid_local',
-            'sys_file_reference',
-            'tablenames = \'be_users\' AND fieldname = \'avatar\' AND ' .
-            'table_local = \'sys_file\' AND uid_foreign = ' . (int)$beUserId .
-            BackendUtility::BEenableFields('sys_file_reference') . BackendUtility::deleteClause('sys_file_reference')
-        );
-        return $file ? $file['uid_local'] : 0;
-    }
+        /** @var QueryBuilder $queryBuilder */
+        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_file_reference');
+        $file = $queryBuilder
+            ->select('uid_local')
+            ->from('sys_file_reference')
+            ->where($queryBuilder->expr()->eq('tablenames', $queryBuilder->createNamedParameter('be_users')))
+            ->andWhere($queryBuilder->expr()->eq('fieldname', $queryBuilder->createNamedParameter('avatar')))
+            ->andWhere($queryBuilder->expr()->eq('table_local', $queryBuilder->createNamedParameter('sys_file')))
+            ->andWhere($queryBuilder->expr()->eq('uid_foreign', (int)$beUserId))
+            ->execute()
+            ->fetchColumn();
 
-    /**
-     * @return \TYPO3\CMS\Core\Database\DatabaseConnection
-     */
-    protected function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
+        return (int)$file;
     }
 }