[TASK] Deprecate signals during extension installation 71/57671/3
authorNicole Cordes <typo3@cordes.co>
Tue, 24 Jul 2018 09:41:04 +0000 (11:41 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 25 Jul 2018 22:14:31 +0000 (00:14 +0200)
The database handling and comparison was streamlined with patch
https://review.typo3.org/57429/. The extension manager uses the
global database compare action after an extension was activated.
For that reason we do not have to maintain a couple of duplicated
signals anymore and can mark them as deprecated.

Resolves: #85462
Releases: master
Change-Id: I7f6d814c43b530bb51737b3457b89c8075c364e7
Reviewed-on: https://review.typo3.org/57671
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Helmut Hummel <typo3@helhum.io>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Documentation/Changelog/9.0/Breaking-82368-SignalAfterExtensionConfigurationWriteRemoved.rst
typo3/sysext/core/Documentation/Changelog/master/Deprecation-85462-SignalHasInstalledExtensionsDeprecated.rst [new file with mode: 0644]
typo3/sysext/core/Documentation/Changelog/master/Deprecation-85462-SignalTablesDefinitionIsBeingBuiltDeprecated.rst [new file with mode: 0644]
typo3/sysext/extensionmanager/Classes/Service/ExtensionManagementService.php
typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php
typo3/sysext/extensionmanager/Tests/Unit/Utility/InstallUtilityTest.php
typo3/sysext/extensionmanager/Tests/UnitDeprecated/Utility/InstallUtilityTest.php [new file with mode: 0644]

index 08cfda5..7639565 100644 (file)
@@ -30,7 +30,8 @@ used signal, relevant mostly only for distributions.
 Migration
 =========
 
-In many cases it should be possible to use signal :php:`hasInstalledExtensions` instead
-which is fired after an extension has been installed.
+In many cases it should be possible to use signal :php:`afterExtensionInstall` of class
+:php:`\TYPO3\CMS\Extensionmanager\Utility\InstallUtility` instead which is fired after an extension
+has been installed.
 
-.. index:: Backend, LocalConfiguration, PHP-API, NotScanned, ext:extensionmanager
\ No newline at end of file
+.. index:: Backend, LocalConfiguration, PHP-API, NotScanned, ext:extensionmanager
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85462-SignalHasInstalledExtensionsDeprecated.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85462-SignalHasInstalledExtensionsDeprecated.rst
new file mode 100644 (file)
index 0000000..919d66b
--- /dev/null
@@ -0,0 +1,40 @@
+.. include:: ../../Includes.txt
+
+================================================================
+Deprecation: #85462 - Signal 'hasInstalledExtensions' deprecated
+================================================================
+
+See :issue:`85462`
+
+Description
+===========
+
+The usage of signal :php:`hasInstalledExtensions` of class
+:php:`\TYPO3\CMS\Extensionmanager\Service\ExtensionManagementService`
+is marked as deprecated and will be removed in v10.
+
+The signal is a duplication of :php:`afterExtensionInstall` that is also emitted during an
+extension installation.
+
+
+Impact
+======
+
+Slots of this signal will get executed in v9 but will not get emitted with v10.
+
+
+Affected Installations
+======================
+
+Extensions that register slots for the signal :php:`hasInstalledExtensions` of class
+:php:`\TYPO3\CMS\Extensionmanager\Service\ExtensionManagementService`.
+
+
+Migration
+=========
+
+Extensions should use the signal :php:`afterExtensionInstall` of class
+:php:`\TYPO3\CMS\Extensionmanager\Utility\InstallUtility` instead which is fired after an
+extension has been installed.
+
+.. index:: Backend, LocalConfiguration, PHP-API, NotScanned, ext:extensionmanager
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85462-SignalTablesDefinitionIsBeingBuiltDeprecated.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85462-SignalTablesDefinitionIsBeingBuiltDeprecated.rst
new file mode 100644 (file)
index 0000000..f1f2606
--- /dev/null
@@ -0,0 +1,42 @@
+.. include:: ../../Includes.txt
+
+======================================================================
+Deprecation: #85462 - Signal 'tablesDefinitionIsBeingBuilt' deprecated
+======================================================================
+
+See :issue:`85462`
+
+Description
+===========
+
+The usage of signal :php:`tablesDefinitionIsBeingBuilt` of class
+:php:`\TYPO3\CMS\Extensionmanager\Utility\InstallUtility`
+is marked as deprecated and will be removed in v10.
+
+The signal is a duplication of :php:`tablesDefinitionIsBeingBuilt` of class
+:php:`\TYPO3\CMS\Install\Service\SqlExpectedSchemaService` that is now also emitted during an
+extension installation.
+
+
+Impact
+======
+
+Slots of this signal will get executed in v9 but will not get emitted with v10. If a slot provides
+SQL definitions a deprecation error is triggered.
+
+
+Affected Installations
+======================
+
+Extensions that register slots for the signal :php:`tablesDefinitionIsBeingBuilt` of class
+:php:`\TYPO3\CMS\Extensionmanager\Utility\InstallUtility`.
+
+
+Migration
+=========
+
+Extensions should use the signal :php:`tablesDefinitionIsBeingBuilt` of class
+:php:`\TYPO3\CMS\Install\Service\SqlExpectedSchemaService` instead which is now fired during an
+extension installation.
+
+.. index:: Backend, LocalConfiguration, PHP-API, NotScanned, ext:extensionmanager
index 4425c45..12a33bb 100644 (file)
@@ -435,6 +435,7 @@ class ExtensionManagementService implements \TYPO3\CMS\Core\SingletonInterface
 
     /**
      * @param string $extensionKey
+     * @deprecated since TYPO3v9, will be removed with TYPO3v10
      */
     protected function emitHasInstalledExtensionSignal($extensionKey)
     {
index 6e1264e..62c93a5 100644 (file)
@@ -359,9 +359,11 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface
      * Additionally adds the table definitions for the cache tables
      *
      * @param array $extension
+     * @deprecated since TYPO3v9, will be removed with TYPO3v10
      */
     public function processDatabaseUpdates(array $extension)
     {
+        trigger_error('This method will be removed in TYPO3 v10.', E_USER_DEPRECATED);
         $extTablesSqlFile = Environment::getPublicPath() . '/' . $extension['siteRelPath'] . 'ext_tables.sql';
         $extTablesSqlContent = '';
         if (file_exists($extTablesSqlFile)) {
@@ -386,8 +388,10 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface
      * Emits a signal to manipulate the tables definitions
      *
      * @param string $extensionKey
-     * @return mixed
      * @throws ExtensionManagerException
+     * @return mixed
+     * @deprecated since TYPO3v9, will be removed with TYPO3v10
+     * @see \TYPO3\CMS\Core\Database\Schema\SqlReader::emitTablesDefinitionIsBeingBuiltSignal
      */
     protected function emitTablesDefinitionIsBeingBuiltSignal($extensionKey)
     {
@@ -406,6 +410,16 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface
                 1382360258
             );
         }
+        if (!empty($sqlString)) {
+            trigger_error(
+                sprintf(
+                    'The signal %s of class %s is deprecated and will be removed in TYPO3 v10.',
+                    'tablesDefinitionIsBeingBuilt',
+                    __CLASS__
+                ),
+                E_USER_DEPRECATED
+            );
+        }
         return $sqlString;
     }
 
@@ -476,9 +490,11 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface
      * Update database / process db updates from ext_tables
      *
      * @param string $rawDefinitions The raw SQL statements from ext_tables.sql
+     * @deprecated since TYPO3v9, will be removed with TYPO3v10
      */
     public function updateDbWithExtTablesSql($rawDefinitions)
     {
+        trigger_error('This method will be removed in TYPO3 v10.', E_USER_DEPRECATED);
         $sqlReader = GeneralUtility::makeInstance(SqlReader::class);
         $statements = $sqlReader->getCreateTableStatementArray($rawDefinitions);
         if (count($statements) !== 0) {
index 2a57865..eefdf84 100644 (file)
@@ -223,89 +223,6 @@ class InstallUtilityTest extends UnitTestCase
         $this->installMock->uninstall($this->extensionKey);
     }
 
-    /**
-     * @test
-     */
-    public function processDatabaseUpdatesCallsUpdateDbWithExtTablesSql()
-    {
-        $extKey = $this->createFakeExtension();
-        $extPath = Environment::getVarPath() . '/tests/' . $extKey . '/';
-        $extTablesFile = $extPath . 'ext_tables.sql';
-        $fileContent = 'DUMMY TEXT TO COMPARE';
-        file_put_contents($extTablesFile, $fileContent);
-        $installMock = $this->getAccessibleMock(
-            InstallUtility::class,
-            ['updateDbWithExtTablesSql', 'importStaticSqlFile', 'importT3DFile'],
-            [],
-            '',
-            false
-        );
-        $dependencyUtility = $this->getMockBuilder(DependencyUtility::class)->getMock();
-        $installMock->_set('dependencyUtility', $dependencyUtility);
-
-        $installMock->expects($this->once())->method('updateDbWithExtTablesSql')->with($this->stringStartsWith($fileContent));
-        $installMock->processDatabaseUpdates($this->fakedExtensions[$extKey]);
-    }
-
-    /**
-     * @test
-     */
-    public function processDatabaseUpdatesCallsImportStaticSqlFile()
-    {
-        $extKey = $this->createFakeExtension();
-        $extensionSiteRelPath = 'typo3temp/var/tests/' . $extKey . '/';
-        $installMock = $this->getAccessibleMock(
-            InstallUtility::class,
-            ['importStaticSqlFile', 'updateDbWithExtTablesSql', 'importT3DFile'],
-            [],
-            '',
-            false
-        );
-        $dependencyUtility = $this->getMockBuilder(DependencyUtility::class)->getMock();
-        $installMock->_set('dependencyUtility', $dependencyUtility);
-        $installMock->expects($this->once())->method('importStaticSqlFile')->with($extensionSiteRelPath);
-        $installMock->processDatabaseUpdates($this->fakedExtensions[$extKey]);
-    }
-
-    /**
-     * @return array
-     */
-    public function processDatabaseUpdatesCallsImportFileDataProvider(): array
-    {
-        return [
-            'T3D file' => [
-                'data.t3d'
-            ],
-            'XML file' => [
-                'data.xml'
-            ]
-        ];
-    }
-
-    /**
-     * @param string $fileName
-     * @test
-     * @dataProvider processDatabaseUpdatesCallsImportFileDataProvider
-     */
-    public function processDatabaseUpdatesCallsImportFile($fileName)
-    {
-        $extKey = $this->createFakeExtension();
-        $absPath = Environment::getPublicPath() . '/' . $this->fakedExtensions[$extKey]['siteRelPath'];
-        GeneralUtility::mkdir($absPath . '/Initialisation');
-        file_put_contents($absPath . '/Initialisation/' . $fileName, 'DUMMY');
-        $installMock = $this->getAccessibleMock(
-            InstallUtility::class,
-            ['updateDbWithExtTablesSql', 'importStaticSqlFile', 'importT3DFile'],
-            [],
-            '',
-            false
-        );
-        $dependencyUtility = $this->getMockBuilder(DependencyUtility::class)->getMock();
-        $installMock->_set('dependencyUtility', $dependencyUtility);
-        $installMock->expects($this->once())->method('importT3DFile')->with($this->fakedExtensions[$extKey]['siteRelPath']);
-        $installMock->processDatabaseUpdates($this->fakedExtensions[$extKey]);
-    }
-
     /**
      * @return array
      */
diff --git a/typo3/sysext/extensionmanager/Tests/UnitDeprecated/Utility/InstallUtilityTest.php b/typo3/sysext/extensionmanager/Tests/UnitDeprecated/Utility/InstallUtilityTest.php
new file mode 100644 (file)
index 0000000..dc1a5cc
--- /dev/null
@@ -0,0 +1,145 @@
+<?php
+declare(strict_types = 1);
+namespace TYPO3\CMS\Extensionmanager\Tests\UnitDeprecated\Utility;
+
+/*
+ * 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\Core\Environment;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extensionmanager\Utility\DependencyUtility;
+use TYPO3\CMS\Extensionmanager\Utility\InstallUtility;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+
+/**
+ * Test case
+ */
+class InstallUtilityTest extends UnitTestCase
+{
+    /**
+     * @var array List of created fake extensions to be deleted in tearDown() again
+     */
+    protected $fakedExtensions = [];
+
+    /**
+     */
+    protected function tearDown()
+    {
+        foreach ($this->fakedExtensions as $fakeExtkey => $fakeExtension) {
+            $this->testFilesToDelete[] = Environment::getVarPath() . '/tests/' . $fakeExtkey;
+        }
+        parent::tearDown();
+    }
+
+    /**
+     * Creates a fake extension inside typo3temp/. No configuration is created,
+     * just the folder
+     *
+     * @return string The extension key
+     */
+    protected function createFakeExtension(): string
+    {
+        $extKey = strtolower($this->getUniqueId('testing'));
+        $absExtPath = Environment::getVarPath() . '/tests/' . $extKey;
+        $relPath = 'typo3temp/var/tests/' . $extKey . '/';
+        GeneralUtility::mkdir($absExtPath);
+        $this->fakedExtensions[$extKey] = [
+            'siteRelPath' => $relPath,
+        ];
+
+        return $extKey;
+    }
+
+    /**
+     * @test
+     */
+    public function processDatabaseUpdatesCallsUpdateDbWithExtTablesSql()
+    {
+        $extKey = $this->createFakeExtension();
+        $extPath = Environment::getVarPath() . '/tests/' . $extKey . '/';
+        $extTablesFile = $extPath . 'ext_tables.sql';
+        $fileContent = 'DUMMY TEXT TO COMPARE';
+        file_put_contents($extTablesFile, $fileContent);
+        $installMock = $this->getAccessibleMock(
+            InstallUtility::class,
+            ['updateDbWithExtTablesSql', 'importStaticSqlFile', 'importT3DFile'],
+            [],
+            '',
+            false
+        );
+        $dependencyUtility = $this->getMockBuilder(DependencyUtility::class)->getMock();
+        $installMock->_set('dependencyUtility', $dependencyUtility);
+
+        $installMock->expects($this->once())->method('updateDbWithExtTablesSql')->with($this->stringStartsWith($fileContent));
+        $installMock->processDatabaseUpdates($this->fakedExtensions[$extKey]);
+    }
+
+    /**
+     * @test
+     */
+    public function processDatabaseUpdatesCallsImportStaticSqlFile()
+    {
+        $extKey = $this->createFakeExtension();
+        $extensionSiteRelPath = 'typo3temp/var/tests/' . $extKey . '/';
+        $installMock = $this->getAccessibleMock(
+            InstallUtility::class,
+            ['importStaticSqlFile', 'updateDbWithExtTablesSql', 'importT3DFile'],
+            [],
+            '',
+            false
+        );
+        $dependencyUtility = $this->getMockBuilder(DependencyUtility::class)->getMock();
+        $installMock->_set('dependencyUtility', $dependencyUtility);
+        $installMock->expects($this->once())->method('importStaticSqlFile')->with($extensionSiteRelPath);
+        $installMock->processDatabaseUpdates($this->fakedExtensions[$extKey]);
+    }
+
+    /**
+     * @return array
+     */
+    public function processDatabaseUpdatesCallsImportFileDataProvider(): array
+    {
+        return [
+            'T3D file' => [
+                'data.t3d',
+            ],
+            'XML file' => [
+                'data.xml',
+            ],
+        ];
+    }
+
+    /**
+     * @param string $fileName
+     * @test
+     * @dataProvider processDatabaseUpdatesCallsImportFileDataProvider
+     */
+    public function processDatabaseUpdatesCallsImportFile($fileName)
+    {
+        $extKey = $this->createFakeExtension();
+        $absPath = Environment::getPublicPath() . '/' . $this->fakedExtensions[$extKey]['siteRelPath'];
+        GeneralUtility::mkdir($absPath . '/Initialisation');
+        file_put_contents($absPath . '/Initialisation/' . $fileName, 'DUMMY');
+        $installMock = $this->getAccessibleMock(
+            InstallUtility::class,
+            ['updateDbWithExtTablesSql', 'importStaticSqlFile', 'importT3DFile'],
+            [],
+            '',
+            false
+        );
+        $dependencyUtility = $this->getMockBuilder(DependencyUtility::class)->getMock();
+        $installMock->_set('dependencyUtility', $dependencyUtility);
+        $installMock->expects($this->once())->method('importT3DFile')->with($this->fakedExtensions[$extKey]['siteRelPath']);
+        $installMock->processDatabaseUpdates($this->fakedExtensions[$extKey]);
+    }
+}