[TASK] DatabaseRecordList::createReferenceHtml uses too much memory
[Packages/TYPO3.CMS.git] / typo3 / sysext / filelist / Classes / FileList.php
index 9909409..df5afc7 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Filelist;
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
+use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Resource\FolderInterface;
 
@@ -879,8 +880,20 @@ class FileList extends \TYPO3\CMS\Backend\RecordList\AbstractRecordList {
                }
                // Look up the file in the sys_refindex.
                // Exclude sys_file_metadata records as these are no use references
-               $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=\'sys_file\' AND ref_uid = ' . (int)$fileOrFolderObject->getUid() . ' AND deleted=0 AND tablename != "sys_file_metadata"');
-               return $this->generateReferenceToolTip($rows, '\'_FILE\', ' . GeneralUtility::quoteJSvalue($fileOrFolderObject->getCombinedIdentifier()));
+               $referenceCount = $this->getDatabaseConnection()->exec_SELECTcountRows(
+                       '*',
+                       'sys_refindex',
+                       'ref_table=\'sys_file\' AND ref_uid = ' . (int)$fileOrFolderObject->getUid() . ' AND deleted=0 AND tablename != "sys_file_metadata"'
+               );
+               return $this->generateReferenceToolTip($referenceCount, '\'_FILE\', ' . GeneralUtility::quoteJSvalue($fileOrFolderObject->getCombinedIdentifier()));
+       }
+
+       /**
+        * Returns the database connection
+        * @return DatabaseConnection
+        */
+       protected function getDatabaseConnection() {
+               return $GLOBALS['TYPO3_DB'];
        }
 
 }