Bug #75281
closedInconsistence on Handling eID requests
0%
Description
If I set a class as eid configuration, an exception in EidRequestHandler is thrown: 'Registered eID has invalid script path.'
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['myeidid'] = \My\AjaxController::class; // Worked in 7.4.0, but not in 7.6.4
But later in TYPO3\CMS\Core\Http\Dispatcher::getCallableFromTarget() the case case where only a class is set would be handled:
// ... // Only a class name is given if (is_string($target) && strpos($target, ':') === false) { $targetObject = GeneralUtility::makeInstance($target); if (!method_exists($targetObject, '__invoke')) { throw new \InvalidArgumentException('Object "' . $target . '" doesn\'t implement an __invoke() method and cannot be used as target.', 1442431631); } return $targetObject; } /// ...
Updated by Markus Klein over 8 years ago
- Status changed from New to Needs Feedback
There is something wrong with your class, since it works for me on several instances and also the Core itself uses this.
Before the exception is thrown there is this check:
// Simple check to make sure that it's not an absolute file (to use the fallback) if (strpos($configuration, '::') !== false || is_callable($configuration)) { /** @var Dispatcher $dispatcher */ $dispatcher = GeneralUtility::makeInstance(Dispatcher::class); $request = $request->withAttribute('target', $configuration); return $dispatcher->dispatch($request, $response); }
It looks like your class is not callable. I guess the class is not loadable.
Updated by Petra Arentzen over 8 years ago
My class is perfectly callable. If I add the method name to it, it is instantiated and called:
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['myeidid'] = \My\AjaxController::class.'::__invoke'
The problem lies in EidRequestHandler::dispatch() where the condition
... if (strpos($configuration, '::') !== false || is_callable($configuration)) { ...
always returns false. '::' is not there because it's a class name, and callable returns false when argument is a class (php 5.6.19) here.
The class was existing before migrating from 7.4.0 to 7.6.2 and worked with autoload.
I think the condition should be something like that:
... if (strpos($configuration, '::') !== false || class_exists($configuration) || is_callable($configuration)) { ...
Updated by Markus Klein over 8 years ago
I double-checked now with the docs. Your syntax is simply wrong, a class name alone is not supported.
You either must specify a callable (className::method) or a filename (legacy).
Updated by Petra Arentzen over 8 years ago
I did not find any documentation at the time I created the ajax handler 3 or 4 month ago nor now. So I had to read the code, debug and do "trial and error".
Fact is, that it worked with Version 7.4.0 and did not with 7.6.4. And there is code to handle a class name in 'EidRequestHandler', but the code for that in "EidRequestHandler" is gone somewhere after 7.4.0. This is a breaking change (undocumented?)- because the new <class>::<method>-synthax is not compatible with version 7.4.0, as the old <class>-synthax is not with 7.6.x.
Would you please be so kind to tell me where I can find the documention you mentioned? I could not find it - and I would be happy to work with a documentation instead of doing time expensive code analysis.
Updated by Markus Klein over 8 years ago
- Status changed from Needs Feedback to Closed
This for sure also mentioned in the https://typo3.org/download/release-notes/whats-new/ slides and all those changes were also linked in the 7 LTS release notes
(https://wiki.typo3.org/TYPO3_CMS_7.6.0#Changes)
If you have Core sources at hand, you can always check sysext/core/Documentation/ChangeLog/* files.
Those docs are rendered to https://docs.typo3.org/typo3cms/extensions/core/ and are also transferred to the wiki (which is linked in the release notes above).