[TASK] Cleanup and deprecate TYPO3_DB occurrences 24/49824/8
authorWouter Wolters <typo3@wouterwolters.nl>
Sat, 3 Sep 2016 09:27:48 +0000 (11:27 +0200)
committerBenni Mack <benni@typo3.org>
Mon, 10 Oct 2016 20:05:33 +0000 (22:05 +0200)
All instances of $GLOBALS[TYPO3_DB] in the TYPO3 Core classes
except for certain highly used functionalities have been removed.

The places where the TYPO3 Core is expected to have subclasses
within extensions have been marked for deprecation.

Resolves: #78224
Releases: master
Change-Id: Ie65878264679b93940ac9fb86c4758576d98c550
Reviewed-on: https://review.typo3.org/49824
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
29 files changed:
typo3/sysext/backend/Classes/Module/AbstractFunctionModule.php
typo3/sysext/backend/Classes/Module/BaseScriptClass.php
typo3/sysext/backend/Classes/View/PageLayoutView.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseEditRowTest.php
typo3/sysext/core/Classes/Category/Collection/CategoryCollection.php
typo3/sysext/core/Classes/Collection/StaticRecordCollection.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Classes/Resource/Index/MetaDataRepository.php
typo3/sysext/core/Classes/Resource/ProcessedFileRepository.php
typo3/sysext/core/Classes/Resource/ResourceFactory.php
typo3/sysext/core/Classes/Resource/ResourceStorage.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-78224-TYPO3_DBOccurrences.rst [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php
typo3/sysext/core/Tests/Unit/Database/Query/Restriction/FrontendRestrictionContainerTest.php
typo3/sysext/extensionmanager/Classes/Domain/Repository/ExtensionRepository.php
typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php
typo3/sysext/feedit/Classes/FrontendEditPanel.php
typo3/sysext/frontend/Classes/Category/Collection/CategoryCollection.php
typo3/sysext/frontend/Classes/ContentObject/ContentContentObject.php
typo3/sysext/frontend/Classes/Plugin/AbstractPlugin.php
typo3/sysext/frontend/Classes/View/AdminPanelView.php
typo3/sysext/install/Classes/Controller/Action/Tool/CleanUp.php
typo3/sysext/install/Classes/Controller/Action/Tool/TestSetup.php
typo3/sysext/install/Classes/Controller/Action/Tool/UpgradeWizard.php
typo3/sysext/install/Classes/Database/DatabaseConnectionMock.php [deleted file]
typo3/sysext/sys_action/Classes/ActionTask.php
typo3/sysext/workspaces/Classes/Domain/Record/AbstractRecord.php
typo3/sysext/workspaces/Classes/ExtDirect/ExtDirectServer.php
typo3/sysext/workspaces/Classes/Service/StagesService.php

index ff30d77..d6b9b7f 100644 (file)
@@ -297,9 +297,11 @@ abstract class AbstractFunctionModule
 
     /**
      * @return DatabaseConnection
 
     /**
      * @return DatabaseConnection
+     * @deprecated since TYPO3 v8, will be removed in TYPO3 v9, use the Doctrine DBAL layer via the ConnectionPool class
      */
     protected function getDatabaseConnection()
     {
      */
     protected function getDatabaseConnection()
     {
+        GeneralUtility::logDeprecatedFunction();
         return $GLOBALS['TYPO3_DB'];
     }
 
         return $GLOBALS['TYPO3_DB'];
     }
 
index 0647346..7d3b6ad 100644 (file)
@@ -391,9 +391,11 @@ class BaseScriptClass
 
     /**
      * @return DatabaseConnection
 
     /**
      * @return DatabaseConnection
+     * @deprecated since TYPO3 v8, will be removed in TYPO3 v9, use the Doctrine DBAL layer via the ConnectionPool class
      */
     protected function getDatabaseConnection()
     {
      */
     protected function getDatabaseConnection()
     {
+        GeneralUtility::logDeprecatedFunction();
         return $GLOBALS['TYPO3_DB'];
     }
 
         return $GLOBALS['TYPO3_DB'];
     }
 
index 2bee528..6ede5cb 100644 (file)
@@ -20,7 +20,6 @@ use TYPO3\CMS\Backend\Controller\PageLayoutController;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Database\ConnectionPool;
-use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Database\Query\QueryHelper;
 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Database\Query\QueryHelper;
 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
@@ -2548,14 +2547,6 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
     }
 
     /**
     }
 
     /**
-     * @return DatabaseConnection
-     */
-    protected function getDatabase()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
-
-    /**
      * @return PageLayoutController
      */
     protected function getPageLayoutController()
      * @return PageLayoutController
      */
     protected function getPageLayoutController()
index cec1930..f431ff4 100644 (file)
@@ -37,9 +37,6 @@ class DatabaseEditRowTest extends UnitTestCase
 
     protected function setUp()
     {
 
     protected function setUp()
     {
-        $this->dbProphecy = $this->prophesize(DatabaseConnection::class);
-        $GLOBALS['TYPO3_DB'] = $this->dbProphecy->reveal();
-
         $this->subject = $this->getMockBuilder(DatabaseEditRow::class)
             ->setMethods(['getDatabaseRow'])
             ->getMock();
         $this->subject = $this->getMockBuilder(DatabaseEditRow::class)
             ->setMethods(['getDatabaseRow'])
             ->getMock();
index 66750e6..773c3a6 100644 (file)
@@ -331,14 +331,4 @@ class CategoryCollection extends AbstractRecordCollection implements EditableCol
     {
         return self::$storageItemsField;
     }
     {
         return self::$storageItemsField;
     }
-
-    /**
-     * Gets the database object.
-     *
-     * @return \TYPO3\CMS\Core\Database\DatabaseConnection
-     */
-    protected static function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
 }
 }
index a74cf64..8aca02b 100644 (file)
@@ -197,14 +197,4 @@ class StaticRecordCollection extends AbstractRecordCollection implements Editabl
         }
         return $relatedRecords;
     }
         }
         return $relatedRecords;
     }
-
-    /**
-     * Gets the database object.
-     *
-     * @return \TYPO3\CMS\Core\Database\DatabaseConnection
-     */
-    protected function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
 }
 }
index 895e543..51ea6f6 100644 (file)
@@ -24,7 +24,6 @@ use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
 use TYPO3\CMS\Core\Charset\CharsetConverter;
 use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Charset\CharsetConverter;
 use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
 use TYPO3\CMS\Core\Database\ConnectionPool;
-use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
 use TYPO3\CMS\Core\Database\Query\QueryHelper;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
 use TYPO3\CMS\Core\Database\Query\QueryHelper;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
@@ -665,13 +664,6 @@ class DataHandler
     protected static $recordPidsForDeletedRecords = [];
 
     /**
     protected static $recordPidsForDeletedRecords = [];
 
     /**
-     * Database layer. Identical to $GLOBALS['TYPO3_DB']
-     *
-     * @var DatabaseConnection
-     */
-    protected $databaseConnection;
-
-    /**
      * Runtime Cache to store and retrieve data computed for a single request
      *
      * @var \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend
      * Runtime Cache to store and retrieve data computed for a single request
      *
      * @var \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend
@@ -690,7 +682,6 @@ class DataHandler
      */
     public function __construct()
     {
      */
     public function __construct()
     {
-        $this->databaseConnection = $GLOBALS['TYPO3_DB'];
         $this->runtimeCache = $this->getRuntimeCache();
     }
 
         $this->runtimeCache = $this->getRuntimeCache();
     }
 
index f4a2c8a..7bdd568 100644 (file)
@@ -46,16 +46,6 @@ class MetaDataRepository implements SingletonInterface
     protected $tableFields = [];
 
     /**
     protected $tableFields = [];
 
     /**
-     * Wrapper method for getting DatabaseConnection
-     *
-     * @return \TYPO3\CMS\Core\Database\DatabaseConnection
-     */
-    protected function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
-
-    /**
      * Returns array of meta-data properties
      *
      * @param File $file
      * Returns array of meta-data properties
      *
      * @param File $file
index d1fcfd8..5068248 100644 (file)
@@ -42,17 +42,11 @@ class ProcessedFileRepository extends AbstractRepository
     protected $table = 'sys_file_processedfile';
 
     /**
     protected $table = 'sys_file_processedfile';
 
     /**
-     * @var \TYPO3\CMS\Core\Database\DatabaseConnection
-     */
-    protected $databaseConnection;
-
-    /**
      * Creates this object.
      */
     public function __construct()
     {
         parent::__construct();
      * Creates this object.
      */
     public function __construct()
     {
         parent::__construct();
-        $this->databaseConnection = $GLOBALS['TYPO3_DB'];
     }
 
     /**
     }
 
     /**
index c8692fb..82f61b1 100644 (file)
@@ -16,7 +16,6 @@ namespace TYPO3\CMS\Core\Resource;
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Database\ConnectionPool;
-use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Resource\Index\FileIndexRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Resource\Index\FileIndexRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -691,12 +690,4 @@ class ResourceFactory implements ResourceFactoryInterface, \TYPO3\CMS\Core\Singl
     {
         return GeneralUtility::makeInstance(Index\Indexer::class, $storage);
     }
     {
         return GeneralUtility::makeInstance(Index\Indexer::class, $storage);
     }
-
-    /**
-     * @return DatabaseConnection
-     */
-    protected function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
 }
 }
index eaa191d..c2fddce 100644 (file)
@@ -15,7 +15,6 @@ namespace TYPO3\CMS\Core\Resource;
  */
 
 use TYPO3\CMS\Core\Database\ConnectionPool;
  */
 
 use TYPO3\CMS\Core\Database\ConnectionPool;
-use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Log\LogManager;
 use TYPO3\CMS\Core\Resource\Exception\InvalidTargetFolderException;
 use TYPO3\CMS\Core\Resource\Index\FileIndexRepository;
 use TYPO3\CMS\Core\Log\LogManager;
 use TYPO3\CMS\Core\Resource\Exception\InvalidTargetFolderException;
 use TYPO3\CMS\Core\Resource\Index\FileIndexRepository;
@@ -2999,12 +2998,4 @@ class ResourceStorage implements ResourceStorageInterface
     {
         return $this->isDefault;
     }
     {
         return $this->isDefault;
     }
-
-    /**
-     * @return DatabaseConnection
-     */
-    protected function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
 }
 }
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-78224-TYPO3_DBOccurrences.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-78224-TYPO3_DBOccurrences.rst
new file mode 100644 (file)
index 0000000..79cfceb
--- /dev/null
@@ -0,0 +1,40 @@
+.. include:: ../../Includes.txt
+
+==========================================
+Deprecation: #78224 - TYPO3_DB occurrences
+==========================================
+
+See :forge:`78224`
+
+Description
+===========
+
+The TYPO3_DB shorthand functionality has been removed for most of the TYPO3 Core PHP classes, excepted for the following locations:
+
+* AbstractPlugin->databaseConnection (protected property)
+* AbstractFunctionModule::getDatabaseConnection()
+* BaseScriptClass::getDatabaseConnection()
+
+For these occurrences extensions might extend the base functionality (e.g. for plugins or modules) and the call to the property and
+protected methods still work.
+
+Calling `$GLOBALS[TYPO3_DB]` is still possible but discouraged.
+
+
+Impact
+======
+
+Calling any of the methods above will trigger a deprecation log entry.
+
+
+Affected Installations
+======================
+
+Any TYPO3 instances with references to TYPO3_DB or references to the occurrences mentioned above.
+
+
+Migration
+=========
+
+Use the ConnectionPool and the QueryBuilder classes to achieve future-proof and proper database abstraction for future TYPO3
+versions.
\ No newline at end of file
index 0e2c1f5..599ecbf 100644 (file)
@@ -15,7 +15,6 @@ namespace TYPO3\CMS\Core\Tests\Unit\DataHandler;
  */
 
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
  */
 
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
-use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\DataHandling\DataHandler;
 use TYPO3\CMS\Core\Tests\AccessibleObjectInterface;
 use TYPO3\CMS\Core\Tests\Unit\DataHandling\Fixtures\AllowAccessHookFixture;
 use TYPO3\CMS\Core\DataHandling\DataHandler;
 use TYPO3\CMS\Core\Tests\AccessibleObjectInterface;
 use TYPO3\CMS\Core\Tests\Unit\DataHandling\Fixtures\AllowAccessHookFixture;
@@ -43,11 +42,6 @@ class DataHandlerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     protected $backEndUser;
 
     /**
     protected $backEndUser;
 
     /**
-     * @var DatabaseConnection|\PHPUnit_Framework_MockObject_MockObject
-     */
-    protected $mockDatabaseConnection;
-
-    /**
      * Set up the tests
      */
     protected function setUp()
      * Set up the tests
      */
     protected function setUp()
@@ -55,8 +49,6 @@ class DataHandlerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         $GLOBALS['TCA'] = [];
         $this->singletonInstances = GeneralUtility::getSingletonInstances();
         $this->backEndUser = $this->createMock(BackendUserAuthentication::class);
         $GLOBALS['TCA'] = [];
         $this->singletonInstances = GeneralUtility::getSingletonInstances();
         $this->backEndUser = $this->createMock(BackendUserAuthentication::class);
-        $this->mockDatabaseConnection = $this->createMock(DatabaseConnection::class);
-        $GLOBALS['TYPO3_DB'] = $this->mockDatabaseConnection;
         $this->subject = $this->getAccessibleMock(DataHandler::class, ['dummy']);
         $this->subject->start([], '', $this->backEndUser);
     }
         $this->subject = $this->getAccessibleMock(DataHandler::class, ['dummy']);
         $this->subject->start([], '', $this->backEndUser);
     }
@@ -275,7 +267,6 @@ class DataHandlerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function inputValueCheckDoesNotCallGetDateTimeFormatsForNonDatetimeFields($tcaFieldConf)
     {
      */
     public function inputValueCheckDoesNotCallGetDateTimeFormatsForNonDatetimeFields($tcaFieldConf)
     {
-        $this->mockDatabaseConnection->expects($this->never())->method('getDateTimeFormats');
         $this->subject->_call('checkValueForInput', '', $tcaFieldConf, '', 0, 0, '');
     }
 
         $this->subject->_call('checkValueForInput', '', $tcaFieldConf, '', 0, 0, '');
     }
 
index 12087a8..2cf9c83 100644 (file)
@@ -15,7 +15,6 @@ namespace TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction;
  * The TYPO3 project - inspiring people to share!
  */
 
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
 use TYPO3\CMS\Frontend\Page\PageRepository;
 
 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
 use TYPO3\CMS\Frontend\Page\PageRepository;
 
@@ -171,14 +170,8 @@ class FrontendRestrictionContainerTest extends AbstractRestrictionTestCase
         $typoScriptFrontendController->gr_list = $feGroupList;
         $typoScriptFrontendController->sys_page = $pageRepository;
 
         $typoScriptFrontendController->gr_list = $feGroupList;
         $typoScriptFrontendController->sys_page = $pageRepository;
 
-        $dbMock = $this->getMockBuilder(DatabaseConnection::class)
-            ->setMethods(['quoteStr'])
-            ->getMock();
-        $dbMock->expects($this->any())->method('quoteStr')->willReturnArgument(0);
-
         $GLOBALS['TSFE'] = $typoScriptFrontendController;
         $GLOBALS['SIM_ACCESS_TIME'] = 42;
         $GLOBALS['TSFE'] = $typoScriptFrontendController;
         $GLOBALS['SIM_ACCESS_TIME'] = 42;
-        $GLOBALS['TYPO3_DB'] = $dbMock;
 
         $subject = new FrontendRestrictionContainer();
         $expression = $subject->buildExpression([$tableName => ''], $this->expressionBuilder);
 
         $subject = new FrontendRestrictionContainer();
         $expression = $subject->buildExpression([$tableName => ''], $this->expressionBuilder);
index ea9e90d..509036a 100644 (file)
@@ -320,7 +320,7 @@ class ExtensionRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
     /**
      * Sets current_version = 1 for all extensions where the extension version is maximal.
      *
     /**
      * Sets current_version = 1 for all extensions where the extension version is maximal.
      *
-     * For performance reasons, the "native" TYPO3_DB is used here directly.
+     * For performance reasons, the "native" database connection is used here directly.
      *
      * @param int $repositoryUid
      * @return void
      *
      * @param int $repositoryUid
      * @return void
index f08f792..5beccb2 100644 (file)
@@ -718,12 +718,4 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface
     {
         $this->signalSlotDispatcher->dispatch(__CLASS__, 'afterExtensionFileImport', [$destinationAbsolutePath, $this]);
     }
     {
         $this->signalSlotDispatcher->dispatch(__CLASS__, 'afterExtensionFileImport', [$destinationAbsolutePath, $this]);
     }
-
-    /**
-     * @return \TYPO3\CMS\Core\Database\DatabaseConnection
-     */
-    protected function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
 }
 }
index ee15e69..9cda050 100644 (file)
@@ -15,7 +15,6 @@ namespace TYPO3\CMS\Feedit;
  */
 use TYPO3\CMS\Backend\FrontendBackendUserAuthentication;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
  */
 use TYPO3\CMS\Backend\FrontendBackendUserAuthentication;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
-use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
@@ -46,13 +45,6 @@ class FrontendEditPanel
     protected $frontendController;
 
     /**
     protected $frontendController;
 
     /**
-     * Property for accessing DatabaseConnection centrally
-     *
-     * @var DatabaseConnection
-     */
-    protected $databaseConnection;
-
-    /**
      * @var FrontendBackendUserAuthentication
      */
     protected $backendUser;
      * @var FrontendBackendUserAuthentication
      */
     protected $backendUser;
@@ -65,13 +57,12 @@ class FrontendEditPanel
     /**
      * Constructor for the edit panel
      *
     /**
      * Constructor for the edit panel
      *
-     * @param DatabaseConnection $databaseConnection
+     * @param mixed $_ Previous the database connection
      * @param TypoScriptFrontendController $frontendController
      * @param FrontendBackendUserAuthentication $backendUser
      */
      * @param TypoScriptFrontendController $frontendController
      * @param FrontendBackendUserAuthentication $backendUser
      */
-    public function __construct(DatabaseConnection $databaseConnection = null, TypoScriptFrontendController $frontendController = null, FrontendBackendUserAuthentication $backendUser = null)
+    public function __construct($_ = null, TypoScriptFrontendController $frontendController = null, FrontendBackendUserAuthentication $backendUser = null)
     {
     {
-        $this->databaseConnection = $databaseConnection ?: $GLOBALS['TYPO3_DB'];
         $this->frontendController = $frontendController ?: $GLOBALS['TSFE'];
         $this->backendUser = $backendUser ?: $GLOBALS['BE_USER'];
         $this->cObj = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
         $this->frontendController = $frontendController ?: $GLOBALS['TSFE'];
         $this->backendUser = $backendUser ?: $GLOBALS['BE_USER'];
         $this->cObj = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
index f01c19f..5bd8c96 100644 (file)
@@ -176,14 +176,4 @@ class CategoryCollection extends \TYPO3\CMS\Core\Category\Collection\CategoryCol
     {
         return $GLOBALS['TSFE'];
     }
     {
         return $GLOBALS['TSFE'];
     }
-
-    /**
-     * Returns the database connection
-     *
-     * @return \TYPO3\CMS\Core\Database\DatabaseConnection
-     */
-    protected static function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
 }
 }
index d210d8f..cf962e4 100644 (file)
@@ -14,7 +14,6 @@ namespace TYPO3\CMS\Frontend\ContentObject;
  * The TYPO3 project - inspiring people to share!
  */
 
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
@@ -135,16 +134,6 @@ class ContentContentObject extends AbstractContentObject
     }
 
     /**
     }
 
     /**
-     * Returns the database connection
-     *
-     * @return DatabaseConnection
-     */
-    protected function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
-
-    /**
      * Returns the frontend controller
      *
      * @return TypoScriptFrontendController
      * Returns the frontend controller
      *
      * @return TypoScriptFrontendController
index 56477a7..96fea2a 100644 (file)
@@ -229,6 +229,7 @@ class AbstractPlugin
      * Property for accessing DatabaseConnection centrally
      *
      * @var DatabaseConnection
      * Property for accessing DatabaseConnection centrally
      *
      * @var DatabaseConnection
+     * @deprecated since TYPO3 v8, will be removed in TYPO3 v9, use the Doctrine DBAL layer via the ConnectionPool class
      */
     protected $databaseConnection;
 
      */
     protected $databaseConnection;
 
@@ -237,7 +238,7 @@ class AbstractPlugin
      * Initializes $this->piVars if $this->prefixId is set to any value
      * Will also set $this->LLkey based on the config.language setting.
      *
      * Initializes $this->piVars if $this->prefixId is set to any value
      * Will also set $this->LLkey based on the config.language setting.
      *
-     * @param DatabaseConnection $databaseConnection
+     * @param DatabaseConnection $databaseConnection, deprecated in TYPO3 v8, will be removed in TYPO3 v9
      * @param TypoScriptFrontendController $frontendController
      */
     public function __construct(DatabaseConnection $databaseConnection = null, TypoScriptFrontendController $frontendController = null)
      * @param TypoScriptFrontendController $frontendController
      */
     public function __construct(DatabaseConnection $databaseConnection = null, TypoScriptFrontendController $frontendController = null)
index eaafce3..f2383aa 100644 (file)
@@ -790,16 +790,6 @@ class AdminPanelView
     }
 
     /**
     }
 
     /**
-     * Returns the database connection
-     *
-     * @return \TYPO3\CMS\Core\Database\DatabaseConnection
-     */
-    protected function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
-
-    /**
      * @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
      */
     protected function getTypoScriptFrontendController()
      * @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
      */
     protected function getTypoScriptFrontendController()
index 2112cf8..f2fbc3c 100644 (file)
@@ -302,9 +302,6 @@ class CleanUp extends Action\AbstractAction
      */
     protected function clearProcessedFiles()
     {
      */
     protected function clearProcessedFiles()
     {
-        // make the DB available
-        $GLOBALS['TYPO3_DB'] = $this->getDatabaseConnection();
-
         $repository = GeneralUtility::makeInstance(ProcessedFileRepository::class);
         $failedDeletions = $repository->removeAll();
         if ($failedDeletions) {
         $repository = GeneralUtility::makeInstance(ProcessedFileRepository::class);
         $failedDeletions = $repository->removeAll();
         if ($failedDeletions) {
index 82e1b6f..2b81ccc 100644 (file)
@@ -223,7 +223,6 @@ class TestSetup extends Action\AbstractAction
      */
     protected function convertImageFormatsToJpg()
     {
      */
     protected function convertImageFormatsToJpg()
     {
-        $this->setUpDatabaseConnectionMock();
         $imageProcessor = $this->initializeImageProcessor();
         $parseTimeStart = GeneralUtility::milliseconds();
 
         $imageProcessor = $this->initializeImageProcessor();
         $parseTimeStart = GeneralUtility::milliseconds();
 
@@ -266,7 +265,6 @@ class TestSetup extends Action\AbstractAction
      */
     protected function writeGifAndPng()
     {
      */
     protected function writeGifAndPng()
     {
-        $this->setUpDatabaseConnectionMock();
         $imageProcessor = $this->initializeImageProcessor();
         $parseTimeStart = GeneralUtility::milliseconds();
 
         $imageProcessor = $this->initializeImageProcessor();
         $parseTimeStart = GeneralUtility::milliseconds();
 
@@ -332,7 +330,6 @@ class TestSetup extends Action\AbstractAction
      */
     protected function scaleImages()
     {
      */
     protected function scaleImages()
     {
-        $this->setUpDatabaseConnectionMock();
         $imageProcessor = $this->initializeImageProcessor();
         $parseTimeStart = GeneralUtility::milliseconds();
 
         $imageProcessor = $this->initializeImageProcessor();
         $parseTimeStart = GeneralUtility::milliseconds();
 
@@ -392,7 +389,6 @@ class TestSetup extends Action\AbstractAction
      */
     protected function combineImages()
     {
      */
     protected function combineImages()
     {
-        $this->setUpDatabaseConnectionMock();
         $imageProcessor = $this->initializeImageProcessor();
         $parseTimeStart = GeneralUtility::milliseconds();
 
         $imageProcessor = $this->initializeImageProcessor();
         $parseTimeStart = GeneralUtility::milliseconds();
 
@@ -445,7 +441,6 @@ class TestSetup extends Action\AbstractAction
      */
     protected function gdlib()
     {
      */
     protected function gdlib()
     {
-        $this->setUpDatabaseConnectionMock();
         $imageProcessor = $this->initializeImageProcessor();
         $parseTimeStart = GeneralUtility::milliseconds();
         $gifOrPng = $imageProcessor->gifExtension;
         $imageProcessor = $this->initializeImageProcessor();
         $parseTimeStart = GeneralUtility::milliseconds();
         $gifOrPng = $imageProcessor->gifExtension;
@@ -696,16 +691,4 @@ class TestSetup extends Action\AbstractAction
         list($version) = explode(' ', trim($version));
         return trim($version);
     }
         list($version) = explode(' ', trim($version));
         return trim($version);
     }
-
-    /**
-     * Instantiate a dummy instance for $GLOBALS['TYPO3_DB'] to
-     * prevent real database calls
-     *
-     * @return void
-     */
-    protected function setUpDatabaseConnectionMock()
-    {
-        $database = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Database\DatabaseConnectionMock::class);
-        $GLOBALS['TYPO3_DB'] = $database;
-    }
 }
 }
index 4b219e2..8b9a0c5 100644 (file)
@@ -325,16 +325,4 @@ class UpgradeWizard extends Action\AbstractAction
         $schemaMigrationService = GeneralUtility::makeInstance(SchemaMigrator::class);
         $schemaMigrationService->install($createTableStatements);
     }
         $schemaMigrationService = GeneralUtility::makeInstance(SchemaMigrator::class);
         $schemaMigrationService->install($createTableStatements);
     }
-
-    /**
-     * Overwrite getDatabase method of abstract!
-     *
-     * Returns $GLOBALS['TYPO3_DB'] directly, since this global is instantiated properly in update wizards
-     *
-     * @return \TYPO3\CMS\Core\Database\DatabaseConnection
-     */
-    protected function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
 }
 }
diff --git a/typo3/sysext/install/Classes/Database/DatabaseConnectionMock.php b/typo3/sysext/install/Classes/Database/DatabaseConnectionMock.php
deleted file mode 100644 (file)
index 1803cbe..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-namespace TYPO3\CMS\Install\Database;
-
-/*
- * 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!
- */
-
-/**
- * A "mock" to suppress database calls on $GLOBALS['TYPO3_DB'].
- * Used in TestSetup install tool action to prevent caching in \TYPO3\CMS\Core\Imaging\GraphicalFunctions
- */
-class DatabaseConnectionMock
-{
-    /**
-     * Get single row mock
-     *
-     * @return NULL
-     */
-    public function exec_SELECTgetSingleRow()
-    {
-        return null;
-    }
-
-    /**
-     * Insert row mock
-     *
-     * @return bool TRUE
-     */
-    public function exec_INSERTquery()
-    {
-        return true;
-    }
-
-    /**
-     * Quote string mock
-     *
-     * @param string $string
-     * @return string
-     */
-    public function fullQuoteStr($string)
-    {
-        return $string;
-    }
-
-    /**
-     * Error mock
-     *
-     * @return string Empty string
-     */
-    public function sql_error()
-    {
-        return '';
-    }
-}
index f6631ac..fe2cbda 100644 (file)
@@ -1053,14 +1053,4 @@ class ActionTask implements \TYPO3\CMS\Taskcenter\TaskInterface
     {
         return $GLOBALS['BE_USER'];
     }
     {
         return $GLOBALS['BE_USER'];
     }
-
-    /**
-     * Returns the database connection
-     *
-     * @return \TYPO3\CMS\Core\Database\DatabaseConnection
-     */
-    protected function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
 }
 }
index b29e1ed..65b59fa 100644 (file)
@@ -45,14 +45,6 @@ abstract class AbstractRecord
     }
 
     /**
     }
 
     /**
-     * @return \TYPO3\CMS\Core\Database\DatabaseConnection
-     */
-    protected static function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
-
-    /**
      * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
      */
     protected static function getBackendUser()
      * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
      */
     protected static function getBackendUser()
index d623eaf..3a17da7 100644 (file)
@@ -18,7 +18,6 @@ use TYPO3\CMS\Backend\Backend\Avatar\Avatar;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Database\ConnectionPool;
-use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Html\RteHtmlParser;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Html\RteHtmlParser;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
@@ -457,14 +456,6 @@ class ExtDirectServer extends AbstractHandler
     }
 
     /**
     }
 
     /**
-     * @return DatabaseConnection;
-     */
-    protected function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
-
-    /**
      * Gets the Grid Data Service.
      *
      * @return GridDataService
      * Gets the Grid Data Service.
      *
      * @return GridDataService
index beaefab..4fcafb7 100644 (file)
@@ -789,12 +789,4 @@ class StagesService implements \TYPO3\CMS\Core\SingletonInterface
     {
         return $GLOBALS['BE_USER'];
     }
     {
         return $GLOBALS['BE_USER'];
     }
-
-    /**
-     * @return \TYPO3\CMS\Core\Database\DatabaseConnection
-     */
-    protected function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
 }
 }