[TASK] Doctrine: Migrate EXT:core FileDeletionAspect 27/48827/3
authorSebastian Bumann <bumann.sebastian@gmail.com>
Wed, 6 Jul 2016 14:55:55 +0000 (16:55 +0200)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Wed, 6 Jul 2016 22:22:12 +0000 (00:22 +0200)
Resolves: #76960
Related: #76871
Releases: master
Change-Id: I6d051b1a8077d1551f0c8cc1831e3292930fb1df
Reviewed-on: https://review.typo3.org/48827
Tested-by: Bamboo TYPO3com <info@typo3.com>
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Tested-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/core/Classes/Resource/Processing/FileDeletionAspect.php

index 562c6e0..9b55fca 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Resource\Processing;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\FileInterface;
 use TYPO3\CMS\Core\Resource\ProcessedFile;
@@ -61,16 +62,6 @@ class FileDeletionAspect
     }
 
     /**
-     * Wrapper method for getting DatabaseConnection
-     *
-     * @return \TYPO3\CMS\Core\Database\DatabaseConnection
-     */
-    protected function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
-
-    /**
      * Cleanup database record for a deleted file
      *
      * @param FileInterface $fileObject
@@ -86,12 +77,22 @@ class FileDeletionAspect
             $this->getMetaDataRepository()->removeByFileUid($fileObject->getUid());
 
             // remove all references
-            $this->getDatabaseConnection()->exec_DELETEquery(
-                'sys_file_reference',
-                'uid_local=' . (int)$fileObject->getUid() . ' AND table_local = \'sys_file\''
-            );
+            GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('sys_file_reference')
+                ->delete(
+                    'sys_file_reference',
+                    [
+                        'uid_local' => (int)$fileObject->getUid(),
+                        'table_local' => 'sys_file'
+                    ]
+                );
         } elseif ($fileObject instanceof ProcessedFile) {
-            $this->getDatabaseConnection()->exec_DELETEquery('sys_file_processedfile', 'uid=' . (int)$fileObject->getUid());
+            GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('sys_file_processedfile')
+                ->delete(
+                    'sys_file_processedfile',
+                    [
+                        'uid' => (int)$fileObject->getUid()
+                    ]
+                );
         }
     }
 
@@ -125,15 +126,18 @@ class FileDeletionAspect
      */
     protected function cleanupCategoryReferences(File $fileObject)
     {
-
         // Retrieve the file metadata uid which is different from the file uid.
         $metadataProperties = $fileObject->_getMetaData();
-
         $metaDataUid = isset($metadataProperties['_ORIG_uid']) ? $metadataProperties['_ORIG_uid'] : $metadataProperties['uid'];
-        $this->getDatabaseConnection()->exec_DELETEquery(
-            'sys_category_record_mm',
-            'uid_foreign=' . (int)$metaDataUid . ' AND tablenames = \'sys_file_metadata\''
-        );
+
+        GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('sys_category_record_mm')
+            ->delete(
+                'sys_category_record_mm',
+                [
+                    'uid_foreign' => (int)$metaDataUid,
+                    'tablenames' => 'sys_file_metadata'
+                ]
+            );
     }
 
     /**
@@ -144,7 +148,6 @@ class FileDeletionAspect
      */
     protected function cleanupProcessedFiles(FileInterface $fileObject)
     {
-
         // only delete processed files of File objects
         if (!$fileObject instanceof File) {
             return;