Project

General

Profile

Actions

Bug #49046

closed

impossible to use repositories or requests to action controller in auth_service

Added by Julian Walter almost 11 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
felogin
Target version:
-
Start date:
2013-06-12
Due date:
% Done:

0%

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

Description

I've implemented my own auth_service which authenticates my users against an ADLDS (ldap from microsoft).
The service works, but it is really not possible to use repositories or create requests to action controllers.
I tried to inject them via "at inject" which leads to a 'Fatal error: Call to a member function xxxfunction() on a non-object error.' of my repositories.
I tried it with \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('PATH\\TO\\MY\\REPOSITORY'); - same shit again
I tried it with
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$objectManager->get('PATH\\TO\\MY\\REPOSITORY');

which leads to 'Fatal error: Call to a member function versionOL() on a non-object in typo3\sysext\extbase\Classes\Persistence\Generic\Storage\Typo3DbBackend.php on line 1203'

Obviously the problem is that there is no TSFE object... pls fix it or give me some advice how to solve it.
I need the repositories to update and import users while logging in, otherwise I have to use oldschool database operations.

Btw I also tried to use:

$request = $objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Request');
$dispatcher = $objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Dispatcher');
$response = $objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Response');
$request->setArguments(SomeArguments);
$request->setControllerExtensionName('MyExtensionName');
$request->setControllerVendorName('MYVENDORNAME');
$request->setControllerName('MyControllerName');
$request->setControllerActionName('myactionname');
$dispatcher->dispatch($request,$response);

it is just IMPOSSIBLE!

Actions #1

Updated by Wouter Wolters over 10 years ago

  • Status changed from New to Needs Feedback

This looks like more an implementation fault then a core issue. Can you ask on the mailinglist for support?

Actions #2

Updated by Philipp Gampe over 10 years ago

You are too early in the bootstrap to use advanced framework magic. Please ask in the newsgroup / forum on how to bootstrap the part you need.

Actions #3

Updated by Alexander Opitz over 10 years ago

BTW: Why not use the existing LDAP Extension, which should work with MS?

Actions #4

Updated by Julian Walter over 10 years ago

Yeah it works with MS, but i needed some special things.

Actions #5

Updated by Alexander Opitz over 10 years ago

  • Is Regression set to No

So could you resolve your problem with help from the mailing list as Wouter and Philipp mentioned?

Actions #6

Updated by Alexander Opitz almost 10 years ago

  • Status changed from Needs Feedback to Closed

No feedback within the last 90 days => closing this ticket.

If you think that this is the wrong decision or experience this issue again, then please write to the mailing list typo3.teams.bugs with issue number and an explanation or open a new ticket and add a relation to this ticket number.

Actions #7

Updated by Xavier Perseguers about 9 years ago

  • Status changed from Closed to Accepted
  • Target version set to next-patchlevel
  • TYPO3 Version changed from 6.1 to 6.2

I confirm this bug with EXT:ig_ldap_sso_auth v3.0-dev which now uses Extbase repositories during the authentication service.

Problem located in \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::getPageRepository() where $GLOBALS['TSFE']->sys_page is an empty string instead of an object.

My code basically does that:

$objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$backendUserGroupRepository = $objectManager->get('TYPO3\\CMS\\Extbase\\Domain\\Repository\\BackendUserGroupRepository');
$userGroup = $userGroupRepository->findByUid(10); // this group exists

This fails with

Table 'typo3_62.tx_extbase_domain_model_backendusergroup' doesn't exist

although yesterday I had the same error (see #66566). This happens when cf_extbase_datamapfactory_datamap has no mapping definition for \TYPO3\CMS\Extbase\Domain\Model\BackendUserGroup (e.g., when cache is cleared and those Core repositories have not yet been used when starting Authentication Service in frontend).

After making sure this is not the case anymore. Bug with ->versionOL() may be reproduced:

Fatal error: Call to a member function versionOL() on string

Problem located in \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::getPageRepository() where $GLOBALS['TSFE']->sys_page is an empty string instead of an object.

Actions #8

Updated by Xavier Perseguers about 9 years ago

So we have basically two bugs here:

Datamap cache

The first one is that the datamap cache is not properly instantiated when empty and trying to use a repository during authentication because this happens in initFEuser() (index_ts.php:109) for the initialization of TSFE and this is most probably just too early for the static TS to have been parsed.

Invalid/incomplete TSFE

Second is the versionOL() problem due to an invalid/incomplete TSFE.

Actions #9

Updated by Helmut Hummel about 9 years ago

  • Status changed from Accepted to Needs Feedback
  • TYPO3 Version changed from 6.2 to 7

I don't think that Extbase should manipulate global state even more to make it possible to be run in such an early bootstrap state.
Extbase is not designed to be used in that context. We will have to live with that with at least with TYPO3 6.2

In auth services you should not rely on such high level functionality. You can still abstract your code to retrieve some entities into your own repositorx implementation.

For future versions it might be possible, but only if the Extbase code is going to be more decoupled and does not depend on TYPO3 BE or Frontend context any more.

Such a feature will require a tough refactoring and a conceptual overhaul though.

I'd like to close this as won't fix. Fine with that? We could open an Epic ticket to decouple and modernize Extbase code though, but I'm not sure when we sill prioritize such a task over other things to solve.

Actions #10

Updated by Xavier Perseguers about 9 years ago

  • Status changed from Needs Feedback to Closed
  • Target version deleted (next-patchlevel)

Sure, I fully agree, I just wanted to post a possible solution if someone encounters the same problem again.

To fix the versionOL(), a possible solution is something like that at the beginning of the authentication service:

// Fix for "Fatal error: Call to a member function versionOL() on string" 
if (TYPO3_MODE === 'FE' && !is_object($GLOBALS['TSFE']->sys_page)) {
    $GLOBALS['TSFE']->sys_page = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
}

The missing database mapping for Extbase is much more tough to cleanly handle but a viable solution may be inspired from http://nerdcenter.de/extbase-typo3-authentication-service/

Actions

Also available in: Atom PDF