[TASK] Doctrine: Migrate BackendUserRepository 99/48499/4
authorXavier Ley <xavierley@gmail.com>
Wed, 8 Jun 2016 09:25:30 +0000 (11:25 +0200)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Wed, 8 Jun 2016 13:19:27 +0000 (15:19 +0200)
Resolves: #76521
Releases: master
Change-Id: I3f785fd3ecdfafbd84987841a92849071b37c63f
Reviewed-on: https://review.typo3.org/48499
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/beuser/Classes/Domain/Repository/BackendUserRepository.php

index e7d190f..dbd0f72 100644 (file)
@@ -14,6 +14,9 @@ namespace TYPO3\CMS\Beuser\Domain\Repository;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Database\ConnectionPool;
+
 /**
  * Repository for \TYPO3\CMS\Beuser\Domain\Model\BackendUser
  */
@@ -101,11 +104,19 @@ class BackendUserRepository extends \TYPO3\CMS\Extbase\Domain\Repository\Backend
     public function findOnline()
     {
         $uids = array();
-        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('DISTINCT ses_userid', 'be_sessions', '');
-        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+
+        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_sessions');
+
+        $res = $queryBuilder
+            ->select('ses_userid')
+            ->from('be_sessions')
+            ->groupBy('ses_userid')
+            ->execute();
+
+        while ($row = $res->fetch()) {
             $uids[] = $row['ses_userid'];
         }
-        $GLOBALS['TYPO3_DB']->sql_free_result($res);
+
         $query = $this->createQuery();
         $query->matching($query->in('uid', $uids));
         return $query->execute();