Commit aeb543de authored by Christian Kuhn's avatar Christian Kuhn
Browse files

Revert "[TASK] Let GeneralUtility::makeInstance() throw exception on unknown class"

This reverts commit 4bc4fb02.

The patch turned a PHP \Error into \Exception, which adds no value,
but can be misleading.

Change-Id: I6cc32da6c0620cb0d717c930d10fa4338d6cefac
Releases: master, 8.7
Resolves: #82131
Reverts: #82131
Reviewed-on: https://review.typo3.org/54004

Reviewed-by: Helmut Hummel's avatarHelmut Hummel <typo3@helhum.io>
Tested-by: Helmut Hummel's avatarHelmut Hummel <typo3@helhum.io>
Reviewed-by: Mathias Brodala's avatarMathias Brodala <mbrodala@pagemachine.de>
Tested-by: Mathias Brodala's avatarMathias Brodala <mbrodala@pagemachine.de>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 1abfcd94
......@@ -3483,9 +3483,6 @@ class GeneralUtility
) {
return array_shift(self::$nonSingletonInstances[$finalClassName]);
}
if (!class_exists($finalClassName)) {
throw new \InvalidArgumentException('Class "' . $className . '" not found', 1503060454);
}
// Create new instance and call constructor with parameters
$instance = new $finalClassName(...$constructorArguments);
// Register new singleton instance
......
......@@ -3771,31 +3771,6 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
GeneralUtility::makeInstance(['foo']);
}
/**
* @test
*/
public function makeInstanceWithUnknownClassThrowsException()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionCode(1503060454);
GeneralUtility::makeInstance('UnknownClass' . time());
}
/**
* @test
*/
public function makeInstanceWithUnknownClassImplementationThrowsException()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionCode(1503060454);
GeneralUtilityFixture::resetFinalClassNameCache();
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][OriginalClassFixture::class] = ['className' => 'UnknownClass' . time()];
GeneralUtility::makeInstance(OriginalClassFixture::class);
}
/**
* @test
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment