Skip to content

Commit

Permalink
[TASK] Remove special singleton handling of makeInstanceService
Browse files Browse the repository at this point in the history
Calling GeneralUtility::makeInstanceService() stores
the instance as "persistent object". Since TYPO3 4.x this has been
dealt with SingletonInterface, which allows far more flexibility
in various places, as throughout the ENTIRE TYPO3 Core already.

The special handling of having GeneralUtility::makeInstanceService()
stores its own Singleton instances is removed, as the method
calls `GeneralUtility::makeInstance()` as well, which does handle
the SingletonInterface anyway.

For services in general (like Authentication Services), it is useful
to not have them as singleton. The current process within
"makeInstanceService()" now allows to properly "reset()" the
functionality anyway by re-calling "init()", which itself
calls "reset()" as well.

As there are no contracts (interfaces) for Services currently,
this should not interfere with anything existing services.

Resolves: #88588
Releases: master
Change-Id: Iba54715c04e510003c095578a237524ebe9f374f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61090
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Tested-by: Daniel Sattler <sattler@b13.de>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Daniel Sattler <sattler@b13.de>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
bmack committed Jun 27, 2019
1 parent 91637f7 commit d4533ea
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions typo3/sysext/core/Classes/Utility/GeneralUtility.php
Expand Up @@ -3655,14 +3655,6 @@ public static function makeInstanceService($serviceType, $serviceSubType = '', $
while ($info = ExtensionManagementUtility::findService($serviceType, $serviceSubType, $excludeServiceKeys)) {
// provide information about requested service to service object
$info = array_merge($info, $requestInfo);
// Check persistent object and if found, call directly and exit.
if (is_object($GLOBALS['T3_VAR']['makeInstanceService'][$info['className']])) {
// update request info in persistent object
$GLOBALS['T3_VAR']['makeInstanceService'][$info['className']]->info = $info;
// reset service and return object
$GLOBALS['T3_VAR']['makeInstanceService'][$info['className']]->reset();
return $GLOBALS['T3_VAR']['makeInstanceService'][$info['className']];
}
$obj = self::makeInstance($info['className']);
if (is_object($obj)) {
if (!@is_callable([$obj, 'init'])) {
Expand All @@ -3672,8 +3664,6 @@ public static function makeInstanceService($serviceType, $serviceSubType = '', $
$obj->info = $info;
// service available?
if ($obj->init()) {
// create persistent object
$GLOBALS['T3_VAR']['makeInstanceService'][$info['className']] = $obj;
return $obj;
}
$error = $obj->getLastErrorArray();
Expand Down

0 comments on commit d4533ea

Please sign in to comment.