[!!!][TASK] Remove support for "selicon_field_path" option 74/60274/8
authorBenni Mack <benni@typo3.org>
Sat, 16 Mar 2019 18:54:17 +0000 (19:54 +0100)
committerBenni Mack <benni@typo3.org>
Sat, 23 Mar 2019 20:29:54 +0000 (21:29 +0100)
The TCA[ctrl][selicon_field_path] option is not necessary
anymore, as support for "internal_type=file" was dropped
for v10.0.

Resolves: #87937
Releases: master
Change-Id: Iae3493c3fe829feb5fff889f274dbab5f0049717
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60274
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Josef Glatz <josefglatz@gmail.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Josef Glatz <josefglatz@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectTreeItemsTest.php
typo3/sysext/core/Classes/Migrations/TcaMigration.php
typo3/sysext/core/Documentation/Changelog/Breaking-87937-TCAOption_selicon_field_path_removed.rst [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Migrations/TcaMigrationTest.php

index 29010ee..2285d16 100644 (file)
@@ -481,7 +481,6 @@ abstract class AbstractItemProvider
             $labelPrefix = $languageService->sL($labelPrefix);
         }
 
-        $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
         $fileRepository = GeneralUtility::makeInstance(FileRepository::class);
 
         while ($foreignRow = $queryResult->fetch()) {
@@ -507,19 +506,6 @@ abstract class AbstractItemProvider
                         $icon = reset($references);
                         $icon = $icon->getPublicUrl();
                     }
-                } else {
-                    $iconPath = '';
-                    if (!empty($GLOBALS['TCA'][$foreignTable]['ctrl']['selicon_field_path'])) {
-                        $iconPath = $GLOBALS['TCA'][$foreignTable]['ctrl']['selicon_field_path'];
-                    }
-                    if ($iconFieldName && $iconPath && $foreignRow[$iconFieldName]) {
-                        // Prepare the row icon if available
-                        $iParts = GeneralUtility::trimExplode(',', $foreignRow[$iconFieldName], true);
-                        $icon = $iconPath . '/' . trim($iParts[0]);
-                    } else {
-                        // Else, determine icon based on record type, or a generic fallback
-                        $icon = $iconFactory->mapRecordTypeToIconIdentifier($foreignTable, $foreignRow);
-                    }
                 }
                 // Add the item
                 $items[] = [
index 2e33db3..a3a814b 100644 (file)
@@ -30,7 +30,6 @@ use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
 use TYPO3\CMS\Core\Database\Query\Restriction\DefaultRestrictionContainer;
 use TYPO3\CMS\Core\Database\RelationHandler;
-use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Imaging\IconRegistry;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
@@ -1683,9 +1682,6 @@ class TcaSelectItemsTest extends UnitTestCase
 
         $GLOBALS['TCA']['fTable'] = [];
 
-        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
-        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
-
         $fileRepositoryProphecy = $this->prophesize(FileRepository::class);
         $fileRepositoryProphecy->findByRelation(Argument::cetera())->shouldNotBeCalled();
         GeneralUtility::setSingletonInstance(FileRepository::class, $fileRepositoryProphecy->reveal());
@@ -1777,9 +1773,6 @@ class TcaSelectItemsTest extends UnitTestCase
 
         $GLOBALS['TCA']['fTable'] = [];
 
-        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
-        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
-
         $fileRepositoryProphecy = $this->prophesize(FileRepository::class);
         $fileRepositoryProphecy->findByRelation(Argument::cetera())->shouldNotBeCalled();
         GeneralUtility::setSingletonInstance(FileRepository::class, $fileRepositoryProphecy->reveal());
@@ -1930,9 +1923,6 @@ class TcaSelectItemsTest extends UnitTestCase
             'columns' => [],
         ];
 
-        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
-        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
-
         $fileRepositoryProphecy = $this->prophesize(FileRepository::class);
         $fileRepositoryProphecy->findByRelation(Argument::cetera())->shouldNotBeCalled();
         GeneralUtility::setSingletonInstance(FileRepository::class, $fileRepositoryProphecy->reveal());
@@ -2026,16 +2016,12 @@ class TcaSelectItemsTest extends UnitTestCase
             'ctrl' => [
                 'label' => 'icon',
                 'selicon_field' => 'icon',
-                'selicon_field_path' => 'uploads/media',
             ],
             'columns' =>[
                 'icon' => [],
             ],
         ];
 
-        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
-        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
-
         $fileRepositoryProphecy = $this->prophesize(FileRepository::class);
         $fileRepositoryProphecy->findByRelation(Argument::cetera())->shouldNotBeCalled();
         GeneralUtility::setSingletonInstance(FileRepository::class, $fileRepositoryProphecy->reveal());
@@ -2075,7 +2061,7 @@ class TcaSelectItemsTest extends UnitTestCase
             0 => [
                 0 => 'foo.jpg',
                 1 => 1,
-                2 => 'uploads/media/foo.jpg', // combination of selicon_field_path and the row value of field 'icon'
+                2 => null,
                 3 => null,
             ],
         ];
@@ -2880,9 +2866,6 @@ class TcaSelectItemsTest extends UnitTestCase
     {
         $GLOBALS['TCA']['foreignTable'] = [];
 
-        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
-        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
-
         $fileRepositoryProphecy = $this->prophesize(FileRepository::class);
         $fileRepositoryProphecy->findByRelation(Argument::cetera())->shouldNotBeCalled();
         GeneralUtility::setSingletonInstance(FileRepository::class, $fileRepositoryProphecy->reveal());
@@ -2944,9 +2927,6 @@ class TcaSelectItemsTest extends UnitTestCase
     {
         $GLOBALS['TCA']['foreignTable'] = [];
 
-        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
-        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
-
         $fileRepositoryProphecy = $this->prophesize(FileRepository::class);
         $fileRepositoryProphecy->findByRelation(Argument::cetera())->shouldNotBeCalled();
         GeneralUtility::setSingletonInstance(FileRepository::class, $fileRepositoryProphecy->reveal());
@@ -3006,9 +2986,6 @@ class TcaSelectItemsTest extends UnitTestCase
     {
         $GLOBALS['TCA']['foreignTable'] = [];
 
-        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
-        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
-
         $fileRepositoryProphecy = $this->prophesize(FileRepository::class);
         $fileRepositoryProphecy->findByRelation(Argument::cetera())->shouldNotBeCalled();
         GeneralUtility::setSingletonInstance(FileRepository::class, $fileRepositoryProphecy->reveal());
@@ -3471,9 +3448,6 @@ class TcaSelectItemsTest extends UnitTestCase
 
         $GLOBALS['TCA'][$foreignTable] = [];
 
-        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
-        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
-
         $fileRepositoryProphecy = $this->prophesize(FileRepository::class);
         $fileRepositoryProphecy->findByRelation(Argument::cetera())->shouldNotBeCalled();
         GeneralUtility::setSingletonInstance(FileRepository::class, $fileRepositoryProphecy->reveal());
index 931cdce..8f15102 100644 (file)
@@ -120,7 +120,6 @@ class TcaSelectTreeItemsTest extends UnitTestCase
 
         $iconFactoryProphecy = $this->prophesize(IconFactory::class);
         GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
-        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
 
         $fileRepositoryProphecy = $this->prophesize(FileRepository::class);
         $fileRepositoryProphecy->findByRelation(Argument::cetera())->shouldNotBeCalled();
@@ -191,7 +190,6 @@ class TcaSelectTreeItemsTest extends UnitTestCase
 
         $iconFactoryProphecy = $this->prophesize(IconFactory::class);
         GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
-        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
 
         $fileRepositoryProphecy = $this->prophesize(FileRepository::class);
         $fileRepositoryProphecy->findByRelation(Argument::cetera())->shouldNotBeCalled();
index e8273a8..bc8b7ef 100644 (file)
@@ -49,6 +49,7 @@ class TcaMigration
         $tca = $this->migrateColumnsConfig($tca);
         $tca = $this->migrateLocalizeChildrenAtParentLocalization($tca);
         $tca = $this->migratePagesLanguageOverlayRemoval($tca);
+        $tca = $this->removeSelIconFieldPath($tca);
 
         return $tca;
     }
@@ -167,4 +168,23 @@ class TcaMigration
         }
         return $tca;
     }
+
+    /**
+     * Removes $TCA[$mytable][ctrl][selicon_field_path]
+     *
+     * @param array $tca
+     * @return array the modified TCA structure
+     */
+    protected function removeSelIconFieldPath(array $tca): array
+    {
+        foreach ($tca as $table => &$configuration) {
+            if (isset($configuration['ctrl']['selicon_field_path'])) {
+                $this->messages[] = 'The TCA table \'' . $table . '\' defines '
+                    . '[ctrl][selicon_field_path] which should be removed from TCA, '
+                    . 'as it is not in use anymore.';
+                unset($configuration['ctrl']['selicon_field_path']);
+            }
+        }
+        return $tca;
+    }
 }
diff --git a/typo3/sysext/core/Documentation/Changelog/Breaking-87937-TCAOption_selicon_field_path_removed.rst b/typo3/sysext/core/Documentation/Changelog/Breaking-87937-TCAOption_selicon_field_path_removed.rst
new file mode 100644 (file)
index 0000000..9247ce1
--- /dev/null
@@ -0,0 +1,36 @@
+.. include:: ../../Includes.txt
+
+==========================================================
+Breaking: #87937 - TCA option "selicon_field_path" removed
+==========================================================
+
+See :issue:`87937`
+
+Description
+===========
+
+The TCA option :php:`$GLOBALS['TCA'][$myTable]['ctrl']['selicon_field_path']` was removed.
+
+The option allowed to show icons in select items when using :php:`$myTable` as a foreign table
+in relations, and was bound to using `selicon_field` as a legacy file ("internal_type=file").
+
+
+Impact
+======
+
+It is now only possible to use `selicon_field` in inline relations towards `sys_file_reference`.
+Setting the `selicon_field_path` has no effect anymore and a deprecation warning will be triggered.
+
+
+Affected Installations
+======================
+
+Any TYPO3 installation with an extension providing TCA with `selicon_field_path`.
+
+
+Migration
+=========
+
+Remove the option `selicon_field_path` and use a inline relation to file references in `selicon_field` instead.
+
+.. index:: TCA, PartiallyScanned, ext:core
index d961204..897be8a 100644 (file)
@@ -137,4 +137,42 @@ class TcaMigrationTest extends UnitTestCase
         $subject = new TcaMigration();
         $this->assertEquals($expected, $subject->migrate($input));
     }
+
+    /**
+     * @test
+     */
+    public function ctrlSelIconFieldPathIsRemoved()
+    {
+        $input = [
+            'aTable' => [
+                'ctrl' => [
+                    'selicon_field' => 'aField',
+                    'selicon_field_path' => 'my/folder'
+                ],
+                'columns' => [
+                    'aField' => [
+                        'config' => [
+                            'type' => 'none',
+                        ],
+                    ],
+                ]
+            ],
+        ];
+        $expected = [
+            'aTable' => [
+                'ctrl' => [
+                    'selicon_field' => 'aField'
+                ],
+                'columns' => [
+                    'aField' => [
+                        'config' => [
+                            'type' => 'none',
+                        ],
+                    ],
+                ],
+            ],
+        ];
+        $subject = new TcaMigration();
+        $this->assertEquals($expected, $subject->migrate($input));
+    }
 }