[TASK] Remove obsolete textmedia content element update wizard 10/52310/3
authorBenjamin Kott <benjamin.kott@wfp2.com>
Sat, 1 Apr 2017 11:46:57 +0000 (13:46 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 2 Apr 2017 18:47:34 +0000 (20:47 +0200)
With the reintroduction of text, textpic and image this wizard becomes
obsolete and can lead to accidential migrations. To avoid unwanted and
unnessesary migrations we are removing this wizard without replacement.

Resolves: #80625
Releases: master
Change-Id: Iaee3692cad4a0d90880dd5b0f2251a470c8b5893
Reviewed-on: https://review.typo3.org/52310
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/install/Classes/Updates/ContentTypesToTextMediaUpdate.php [deleted file]
typo3/sysext/install/Tests/Unit/Updates/ContentTypesToTextMediaUpdateTest.php [deleted file]
typo3/sysext/install/ext_localconf.php

diff --git a/typo3/sysext/install/Classes/Updates/ContentTypesToTextMediaUpdate.php b/typo3/sysext/install/Classes/Updates/ContentTypesToTextMediaUpdate.php
deleted file mode 100644 (file)
index 743ab2d..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-<?php
-namespace TYPO3\CMS\Install\Updates;
-
-/*
- * 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!
- */
-
-use TYPO3\CMS\Core\Database\Connection;
-use TYPO3\CMS\Core\Database\ConnectionPool;
-use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-
-/**
- * Migrate CTypes 'text', 'image' and 'textpic' to 'textmedia' for extension 'frontend'
- */
-class ContentTypesToTextMediaUpdate extends AbstractUpdate
-{
-    /**
-     * @var string
-     */
-    protected $title = 'Migrate CTypes text, image and textpic to textmedia and move file relations from "image" to "asset_references"';
-
-    /**
-     * Checks if an update is needed
-     *
-     * @param string &$description The description for the update
-     * @return bool Whether an update is needed (TRUE) or not (FALSE)
-     */
-    public function checkForUpdate(&$description)
-    {
-        if (
-            !ExtensionManagementUtility::isLoaded('fluid_styled_content')
-            || ExtensionManagementUtility::isLoaded('css_styled_content')
-            || $this->isWizardDone()
-        ) {
-            return false;
-        }
-
-        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
-            ->getQueryBuilderForTable('tt_content');
-        $queryBuilder->getRestrictions()->removeAll();
-        $nonTextmediaCount = $queryBuilder->count('uid')
-            ->from('tt_content')
-            ->where(
-                $queryBuilder->expr()->in(
-                    'CType',
-                    $queryBuilder->createNamedParameter(
-                        ['text', 'image', 'textpic'],
-                        Connection::PARAM_STR_ARRAY
-                    )
-                )
-            )
-            ->execute()->fetchColumn(0);
-
-        if ((bool)$nonTextmediaCount) {
-            $description = 'The extension "fluid_styled_content" is using a new CType, textmedia, ' .
-                'which replaces the CTypes text, image and textpic. ' .
-                'This update wizard migrates these old CTypes to the new one in the database. ' .
-                'If backend groups have the explicit deny/allow flag set for any of the old CTypes, ' .
-                'the according flag for the CType textmedia is set as well.';
-        }
-
-        return (bool)$nonTextmediaCount;
-    }
-
-    /**
-     * Performs the database update if old CTypes are available
-     *
-     * @param array &$databaseQueries Queries done in this update
-     * @param string &$customMessage Custom message
-     * @return bool
-     */
-    public function performUpdate(array &$databaseQueries, &$customMessage)
-    {
-        $ttContentConnection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tt_content');
-        $falConnection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('sys_file_reference');
-
-        // Update text to textmedia
-        $queryBuilder = $ttContentConnection->createQueryBuilder();
-        $queryBuilder->update('tt_content')
-            ->where(
-                $queryBuilder->expr()->eq(
-                    'CType',
-                    $queryBuilder->createNamedParameter('text', \PDO::PARAM_STR)
-                )
-            )
-            ->set('CType', 'textmedia');
-        $databaseQueries[] = $queryBuilder->getSQL();
-        $queryBuilder->execute();
-
-        // Update 'textpic' and 'image' records
-        $queryBuilder = $ttContentConnection->createQueryBuilder();
-        $queryBuilder->getRestrictions()->removeAll();
-        $statement = $queryBuilder->select('uid', 'image', 'CType')
-            ->from('tt_content')
-            ->where(
-                $queryBuilder->expr()->orX(
-                    $queryBuilder->expr()->eq(
-                        'CType',
-                        $queryBuilder->createNamedParameter('textpic', \PDO::PARAM_STR)
-                    ),
-                    $queryBuilder->expr()->eq(
-                        'CType',
-                        $queryBuilder->createNamedParameter('image', \PDO::PARAM_STR)
-                    )
-                )
-            )->execute();
-        while ($ttContentRow = $statement->fetch()) {
-            $falQueryBuilder = $falConnection->createQueryBuilder();
-            $falQueryBuilder->update('sys_file_reference')
-                ->where(
-                    $queryBuilder->expr()->eq(
-                        'uid_foreign',
-                        $falQueryBuilder->createNamedParameter($ttContentRow['uid'], \PDO::PARAM_INT)
-                    ),
-                    $queryBuilder->expr()->eq(
-                        'tablenames',
-                        $falQueryBuilder->createNamedParameter('tt_content', \PDO::PARAM_STR)
-                    ),
-                    $queryBuilder->expr()->eq(
-                        'fieldname',
-                        $falQueryBuilder->createNamedParameter('image', \PDO::PARAM_STR)
-                    )
-                )
-                ->set('fieldname', 'assets');
-            $databaseQueries[] = $falQueryBuilder->getSQL();
-            $falQueryBuilder->execute();
-
-            $ttContentQueryBuilder = $ttContentConnection->createQueryBuilder();
-            $ttContentQueryBuilder->update('tt_content')
-                ->where(
-                    $queryBuilder->expr()->eq(
-                        'uid',
-                        $ttContentQueryBuilder->createNamedParameter($ttContentRow['uid'], \PDO::PARAM_INT)
-                    )
-                )
-                ->set('CType', 'textmedia')
-                ->set('assets', (int)$ttContentRow['image'])
-                ->set('image', 0);
-            $databaseQueries[] = $ttContentQueryBuilder->getSQL();
-            $ttContentQueryBuilder->execute();
-        }
-
-        // Update explicitDeny - ALLOW
-        $beGroupsConnection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('be_groups');
-        $queryBuilder = $beGroupsConnection->createQueryBuilder();
-        $queryBuilder->getRestrictions()->removeAll();
-        $statement = $queryBuilder->select('uid', 'explicit_allowdeny')
-            ->from('be_groups')
-            ->where(
-                $queryBuilder->expr()->andX(
-                    $queryBuilder->expr()->notLike(
-                        'explicit_allowdeny',
-                        $queryBuilder->createNamedParameter('%tt_content:CType:textmedia:ALLOW%', \PDO::PARAM_STR)
-                    ),
-                    $queryBuilder->expr()->orX(
-                        $queryBuilder->expr()->like(
-                            'explicit_allowdeny',
-                            $queryBuilder->createNamedParameter('%tt_content:CType:textpic:ALLOW%', \PDO::PARAM_STR)
-                        ),
-                        $queryBuilder->expr()->like(
-                            'explicit_allowdeny',
-                            $queryBuilder->createNamedParameter('%tt_content:CType:image:ALLOW%', \PDO::PARAM_STR)
-                        ),
-                        $queryBuilder->expr()->like(
-                            'explicit_allowdeny',
-                            $queryBuilder->createNamedParameter('%tt_content:CType:text:ALLOW%', \PDO::PARAM_STR)
-                        )
-                    )
-                )
-            )->execute();
-        while ($beGroupsRow = $statement->fetch()) {
-            $queryBuilder = $beGroupsConnection->createQueryBuilder();
-            $queryBuilder->update('be_groups')
-                ->where(
-                    $queryBuilder->expr()->eq(
-                        'uid',
-                        $queryBuilder->createNamedParameter($beGroupsRow['uid'], \PDO::PARAM_INT)
-                    )
-                )
-                ->set('explicit_allowdeny', $beGroupsRow['explicit_allowdeny'] . ',tt_content:CType:textmedia:ALLOW');
-            $databaseQueries[] = $queryBuilder->getSQL();
-            $queryBuilder->execute();
-        }
-
-        // Update explicitDeny - DENY
-        $queryBuilder = $beGroupsConnection->createQueryBuilder();
-        $queryBuilder->getRestrictions()->removeAll();
-        $statement = $queryBuilder->select('uid', 'explicit_allowdeny')
-            ->from('be_groups')
-            ->where(
-                $queryBuilder->expr()->andX(
-                    $queryBuilder->expr()->notLike(
-                        'explicit_allowdeny',
-                        $queryBuilder->createNamedParameter('%tt_content:CType:textmedia:DENY%', \PDO::PARAM_STR)
-                    ),
-                    $queryBuilder->expr()->orX(
-                        $queryBuilder->expr()->like(
-                            'explicit_allowdeny',
-                            $queryBuilder->createNamedParameter('%tt_content:CType:textpic:DENY%', \PDO::PARAM_STR)
-                        ),
-                        $queryBuilder->expr()->like(
-                            'explicit_allowdeny',
-                            $queryBuilder->createNamedParameter('%tt_content:CType:image:DENY%', \PDO::PARAM_STR)
-                        ),
-                        $queryBuilder->expr()->like(
-                            'explicit_allowdeny',
-                            $queryBuilder->createNamedParameter('%tt_content:CType:text:DENY%', \PDO::PARAM_STR)
-                        )
-                    )
-                )
-            )->execute();
-        while ($beGroupsRow = $statement->fetch()) {
-            $queryBuilder = $beGroupsConnection->createQueryBuilder();
-            $queryBuilder->update('be_groups')
-                ->where(
-                    $queryBuilder->expr()->eq(
-                        'uid',
-                        $queryBuilder->createNamedParameter($beGroupsRow['uid'], \PDO::PARAM_INT)
-                    )
-                )
-                ->set('explicit_allowdeny', $beGroupsRow['explicit_allowdeny'] . ',tt_content:CType:textmedia:DENY');
-            $databaseQueries[] = $queryBuilder->getSQL();
-            $queryBuilder->execute();
-        }
-
-        $this->markWizardAsDone();
-
-        return true;
-    }
-}
diff --git a/typo3/sysext/install/Tests/Unit/Updates/ContentTypesToTextMediaUpdateTest.php b/typo3/sysext/install/Tests/Unit/Updates/ContentTypesToTextMediaUpdateTest.php
deleted file mode 100644 (file)
index 2fb098b..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-namespace TYPO3\CMS\Install\Tests\Unit\Updates;
-
-/*
- * 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!
- */
-
-use Prophecy\Prophecy\ObjectProphecy;
-use Prophecy\Prophet;
-use TYPO3\CMS\Core\Package\PackageManager;
-use TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase;
-use TYPO3\CMS\Core\Tests\Unit\Utility\AccessibleProxies\ExtensionManagementUtilityAccessibleProxy;
-use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
-use TYPO3\CMS\Install\Updates\ContentTypesToTextMediaUpdate as UpdateWizard;
-
-/**
- * Test Class for ContentTypesToTextMediaUpdate
- */
-class ContentTypesToTextMediaUpdateTest extends BaseTestCase
-{
-    /**
-     * @var PackageManager|ObjectProphecy
-     */
-    protected $packageManagerProphecy;
-
-    /**
-     * @var ObjectProphecy
-     */
-    protected $dbProphecy;
-
-    /**
-     * @var \TYPO3\CMS\Core\Package\PackageManager
-     */
-    protected $backupPackageManager;
-
-    /**
-     * @var ObjectProphecy
-     */
-    protected $updateWizard;
-
-    /**
-     * Set up
-     */
-    public function setUp()
-    {
-        unset($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']);
-        $prophet = new Prophet();
-        $this->packageManagerProphecy = $prophet->prophesize(PackageManager::class);
-        $this->updateWizard = new UpdateWizard();
-        $this->backupPackageManager = ExtensionManagementUtilityAccessibleProxy::getPackageManager();
-        ExtensionManagementUtility::setPackageManager($this->packageManagerProphecy->reveal());
-    }
-
-    /**
-     * Tear down
-     */
-    public function tearDown()
-    {
-        ExtensionManagementUtilityAccessibleProxy::setPackageManager($this->backupPackageManager);
-        parent::tearDown();
-    }
-
-    /**
-     * @test
-     */
-    public function updateWizardDoesNotRunIfCssStyledContentIsInstalled()
-    {
-        $this->packageManagerProphecy->isPackageActive('fluid_styled_content')->willReturn(true);
-        $this->packageManagerProphecy->isPackageActive('css_styled_content')->willReturn(true);
-
-        $description = '';
-        $this->assertFalse($this->updateWizard->checkForUpdate($description));
-    }
-}
index d2318aa..a4dcc72 100644 (file)
@@ -11,7 +11,6 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['filesReplace
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['tableCType'] = \TYPO3\CMS\Install\Updates\TableFlexFormToTtContentFieldsUpdate::class;
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\TYPO3\CMS\Install\Updates\FileListInAccessModuleListUpdate::class] = \TYPO3\CMS\Install\Updates\FileListInAccessModuleListUpdate::class;
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\TYPO3\CMS\Install\Updates\FileListIsStartModuleUpdate::class] = \TYPO3\CMS\Install\Updates\FileListIsStartModuleUpdate::class;
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['textmediaCType'] = \TYPO3\CMS\Install\Updates\ContentTypesToTextMediaUpdate::class;
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\TYPO3\CMS\Install\Updates\WorkspacesNotificationSettingsUpdate::class] = \TYPO3\CMS\Install\Updates\WorkspacesNotificationSettingsUpdate::class;
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['textmediaAssets'] = \TYPO3\CMS\Install\Updates\MigrateMediaToAssetsForTextMediaCe::class;
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['compatibility6Extension'] = \TYPO3\CMS\Install\Updates\Compatibility6ExtractionUpdate::class;