[TASK] Doctrine: Migrate two admin_get_fields() 54/49554/4
authorChristian Kuhn <lolli@schwarzbu.ch>
Tue, 23 Aug 2016 12:36:03 +0000 (14:36 +0200)
committerBenni Mack <benni@typo3.org>
Tue, 23 Aug 2016 13:01:43 +0000 (15:01 +0200)
Change-Id: Ib945ec9c9e5d6e0ca7575536234ee15c7d8fac27
Resolves: #77606
Releases: master
Reviewed-on: https://review.typo3.org/49554
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Bamboo TYPO3com <info@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/core/Classes/Resource/Index/MetaDataRepository.php
typo3/sysext/core/Classes/Resource/ProcessedFileRepository.php
typo3/sysext/core/Tests/Unit/Resource/ProcessedFileRepositoryTest.php [deleted file]

index 7aeb3ba..edb2adc 100644 (file)
@@ -171,7 +171,10 @@ class MetaDataRepository implements SingletonInterface
     public function update($fileUid, array $data)
     {
         if (empty($this->tableFields)) {
-            $this->tableFields = $this->getDatabaseConnection()->admin_get_fields($this->tableName);
+            $this->tableFields = GeneralUtility::makeInstance(ConnectionPool::class)
+                ->getConnectionForTable($this->tableName)
+                ->getSchemaManager()
+                ->listTableColumns($this->tableName);
         }
         $updateRow = array_intersect_key($data, $this->tableFields);
         if (array_key_exists('uid', $updateRow)) {
index 13b22ab..334c07f 100644 (file)
@@ -284,7 +284,11 @@ class ProcessedFileRepository extends AbstractRepository
      */
     protected function cleanUnavailableColumns(array $data)
     {
-        return array_intersect_key($data, $this->databaseConnection->admin_get_fields($this->table));
+        $tableColumns = GeneralUtility::makeInstance(ConnectionPool::class)
+            ->getConnectionForTable($this->table)
+            ->getSchemaManager()
+            ->listTableColumns($this->table);
+        return array_intersect_key($data, $tableColumns);
     }
 
     /**
diff --git a/typo3/sysext/core/Tests/Unit/Resource/ProcessedFileRepositoryTest.php b/typo3/sysext/core/Tests/Unit/Resource/ProcessedFileRepositoryTest.php
deleted file mode 100644 (file)
index e039330..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-namespace TYPO3\CMS\Core\Tests\Unit\Resource;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-/**
- * Processed file repository test
- */
-class ProcessedFileRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
-{
-    /**
-     * @test
-     */
-    public function cleanUnavailableColumnsWorks()
-    {
-        $fixture = $this->getAccessibleMock(\TYPO3\CMS\Core\Resource\ProcessedFileRepository::class, array('dummy'), array(), '', false);
-        $databaseMock = $this->getAccessibleMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array('admin_get_fields'));
-        $databaseMock->expects($this->once())->method('admin_get_fields')->will($this->returnValue(array('storage' => '', 'checksum' => '')));
-        $fixture->_set('databaseConnection', $databaseMock);
-
-        $actual = $fixture->_call('cleanUnavailableColumns', array('storage' => 'a', 'checksum' => 'b', 'key3' => 'c'));
-
-        $this->assertSame(array('storage' => 'a', 'checksum' => 'b'), $actual);
-    }
-}