Issue Bug Closed

#81472Wrong exception is thrown in PageRepository

Dmitry Dulepov 06/05/17, 14:43 updated 10/02/18, 11:00

Description

If PsgeRepository’s init hook is of the wrong class, an exception should be thrown with a corresponding message. However there is an error that prevents an exception from being thrown. Instead a PHP fatal error is thrown.

The problem is that $hookObject is used instead of $classRef when generating the exception.

Uncaught TYPO3 Exception
#1: PHP Catchable Fatal Error: Object of class Vendor\Extension\Hooks\PageRepositoryFilter could not be converted to string in /home/***/vendor/typo3/cms/typo3/sysext/frontend/Classes/Page/PageRepository.php line 200 (More information)

TYPO3\CMS\Core\Error\Exception thrown in file
/home/***/vendor/typo3/cms/typo3/sysext/core/Classes/Error/ErrorHandler.php in line 111.

13 TYPO3\CMS\Core\Error\ErrorHandler::handleError(4096, "Object of class Vendor\Extension\Hooks\PageRepositoryFilter could not be converted to string", "/home/***/vendor/typo3/cms/typo3/sysext/frontend/Classes/Page/PageRepository.php", 200, array)

/home/***/vendor/typo3/cms/typo3/sysext/frontend/Classes/Page/PageRepository.php:
00198:                 $hookObject = GeneralUtility::makeInstance($classRef);
00199:                 if (!$hookObject instanceof PageRepositoryInitHookInterface) {
00200:                     throw new \UnexpectedValueException($hookObject . ' must implement interface ' . PageRepositoryInitHookInterface::class, 1379579812);
00201:                 }
00202:                 $hookObject->init_postProcess($this);

Reviews 2