Project

General

Profile

Actions

Bug #75281

closed

Inconsistence on Handling eID requests

Added by Petra Arentzen about 8 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2016-03-28
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
5.6
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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;
        }
/// ...
Actions #1

Updated by Markus Klein about 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.

Actions #2

Updated by Petra Arentzen about 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)) {
...
Actions #3

Updated by Markus Klein about 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).

Actions #4

Updated by Petra Arentzen about 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.

Actions #5

Updated by Markus Klein about 8 years ago

  • Status changed from Needs Feedback to Closed

https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.5/Important-69846-HaveEIDsWithPSR-7WithoutControllerInterface.html

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).

Actions

Also available in: Atom PDF