From aeb543deb75aeec60a94d66ec83382ea7789f978 Mon Sep 17 00:00:00 2001 From: Christian Kuhn <lolli@schwarzbu.ch> Date: Fri, 8 Sep 2017 12:14:36 +0200 Subject: [PATCH] Revert "[TASK] Let GeneralUtility::makeInstance() throw exception on unknown class" This reverts commit 4bc4fb0273cb1b2cbdb025558b5c3ae9d76b0394. 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 <typo3@helhum.io> Tested-by: Helmut Hummel <typo3@helhum.io> Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de> Tested-by: Mathias Brodala <mbrodala@pagemachine.de> Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../core/Classes/Utility/GeneralUtility.php | 3 --- .../Tests/Unit/Utility/GeneralUtilityTest.php | 25 ------------------- 2 files changed, 28 deletions(-) diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php index 99e41497faa1..7ad9352760ae 100644 --- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php +++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php @@ -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 diff --git a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php index 9d77dace880b..bc708d0e0d67 100644 --- a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php +++ b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php @@ -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 */ -- GitLab