Skip to content

Commit

Permalink
[BUGFIX] Use RuntimeException instead of die()
Browse files Browse the repository at this point in the history
There are a few places left where Kasper-Kode stopped
a process with die(). Nowadays, with PHP 7, Errors and
Exceptions are used in order to avoid the full stop
of a process.

Using Exceptions instead of die() allows for
ExceptionHandlers to handle such an error and
return a proper HTTP response if called from the web.

Resolves: #89128
Releases: master
Change-Id: Ia50863104fb91303ca3b2ae5ac5cd1466fa982b6
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61659
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Richard Haeser <richard@maxserv.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
  • Loading branch information
bmack authored and georgringer committed Sep 11, 2019
1 parent aeff733 commit 2d8a956
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions typo3/sysext/backend/Classes/Utility/BackendUtility.php
Expand Up @@ -2816,6 +2816,7 @@ public static function getUpdateSignalCode()
* @param string $type If type is 'ses' then the data is stored as session-lasting data. This means that it'll be wiped out the next time the user logs in.
* @param string $dontValidateList dontValidateList can be used to list variables that should not be checked if their value is found in the MOD_MENU array. Used for dynamically generated menus.
* @param string $setDefaultList List of default values from $MOD_MENU to set in the output array (only if the values from MOD_MENU are not arrays)
* @throws \RuntimeException
* @return array The array $settings, which holds a key for each MOD_MENU key and the values of each key will be within the range of values for each menuitem
*/
public static function getModuleData(
Expand Down Expand Up @@ -2868,14 +2869,14 @@ public static function getModuleData(
}
}
} else {
die('No menu!');
throw new \RuntimeException('No menu', 1568119229);
}
if ($changed) {
$beUser->pushModuleData($modName, $settings);
}
return $settings;
}
die('Wrong module name: "' . $modName . '"');
throw new \RuntimeException('Wrong module name "' . $modName . '"', 1568119221);
}

/*******************************************
Expand Down
5 changes: 3 additions & 2 deletions typo3/sysext/core/Classes/Utility/GeneralUtility.php
Expand Up @@ -3717,6 +3717,7 @@ public static function flushInternalRuntimeCaches()
* @param string $serviceType Type of service (service key).
* @param string $serviceSubType Sub type like file extensions or similar. Defined by the service.
* @param mixed $excludeServiceKeys List of service keys which should be excluded in the search for a service. Array or comma list.
* @throws \RuntimeException
* @return object|string[] The service object or an array with error infos.
*/
public static function makeInstanceService($serviceType, $serviceSubType = '', $excludeServiceKeys = [])
Expand All @@ -3736,8 +3737,8 @@ public static function makeInstanceService($serviceType, $serviceSubType = '', $
$obj = self::makeInstance($info['className']);
if (is_object($obj)) {
if (!@is_callable([$obj, 'init'])) {
// use silent logging??? I don't think so.
die('Broken service:' . DebugUtility::viewArray($info));
self::getLogger()->error('Requested service ' . $info['className'] . ' has no init() method.', ['service' => $info]);
throw new \RuntimeException('Broken service: ' . $info['className'], 1568119209);
}
$obj->info = $info;
// service available?
Expand Down

0 comments on commit 2d8a956

Please sign in to comment.