Bug #54014
closedcli_dispatch.phpsh scheduler won't run because of BackendUserAuthentication?
0%
Description
System:
- TYPO3 v6.1.6
- PHP Version 5.3.10
First of all, I'm not a coding master. But I try too understand what happens in the TYPO3 Core. ;-)
To test the scheduler functionality, I added a Scheduler-Example-TestTask with recurring ("*/1 * * * *"). If I run this manually, the test email arrived. Now I wait a few minutes an refresh the scheduler page. The TestTask is now displayed as delayed (as expected with none existing cronjob).
Now if I run "typo3\cli_dispatch.phpsh scheduler" manually in the SSH console, nothing happen. Normally this work (in older TYPO3-Versions like 4.7). I have tried to trace down the problem. I have added "// => the skript stops here" in the code below.
In "typo3_src-6.1.6/typo3/cli_dispatch.phpsh":
\TYPO3\CMS\Core\Core\Bootstrap::getInstance() ->loadExtensionTables(TRUE) ->initializeBackendUser() ->initializeBackendUserMounts() // => the skript stops here ->initializeLanguageObject();
So the next step is "typo3_src-6.1.6/typo3/sysext/core/Classes/Core/Bootstrap.php":
/** * Initialize backend user mount points * * @return \TYPO3\CMS\Core\Core\Bootstrap * @internal This is not a public API method, do not use in own extensions */ public function initializeBackendUserMounts() { // Includes deleted mount pages as well! @TODO: Figure out why ... $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts(); $GLOBALS['BE_USER']->getFileStorages(); // => the skript stops here $GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->groupData['filemounts']; return $this; }
And the next step is "typo3_src-6.1.6/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php":
/** * Returns an array with the filemounts for the user. * Each filemount is represented with an array of a "name", "path" and "type". * If no filemounts an empty array is returned. * * @api * @return \TYPO3\CMS\Core\Resource\ResourceStorage[] */ public function getFileStorages() { // Initializing file mounts after the groups are fetched if ($this->fileStorages === NULL) { $this->initializeFileStorages(); // => the skript stops here } return $this->fileStorages; }
And the next step is again "typo3_src-6.1.6/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php":
/** * Sets up all file storages for a user. * Needs to be called AFTER the groups have been loaded. * * @return void */ protected function initializeFileStorages() { $this->fileStorages = array(); /** @var $storageRepository \TYPO3\CMS\Core\Resource\StorageRepository */ var_dump('TEST'); // => this is shown in the console $storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\StorageRepository'); // => the skript stops here // Admin users have all file storages visible, without any filters if ($this->isAdmin()) { $storageObjects = $storageRepository->findAll(); foreach ($storageObjects as $storageObject) { $this->fileStorages[$storageObject->getUid()] = $storageObject; } } else { // Regular users only have storages that are defined in their filemounts // Permissions and file mounts for the storage are added in StoragePermissionAspect foreach ($this->getFileMountRecords() as $row) { if (!array_key_exists(intval($row['base']), $this->fileStorages)) { $storageObject = $storageRepository->findByUid($row['base']); $this->fileStorages[$storageObject->getUid()] = $storageObject; } } } // This has to be called always in order to set certain filters $this->evaluateUserSpecificFileFilterSettings(); }
In my opinion, "\TYPO3\CMS\Core\Utility\GeneralUtility" isn't available at this time, when the cli-script is call the functionallity.
If I comment out the line "$this->initializeFileStorages()" in "BackendUserAuthentication->getFileStorages()" the scheduler works as it should and I recieve the Testmail from the TestTask.
So I consult you all. What is to do? How can I help?
Updated by Markus Klein almost 11 years ago
Hi David,
thanks for your analysis. Are you getting any specific error message?
It does not necessarily mean that GeneralUtility is not available, it might also be an issue with StorageRepository.
Updated by Markus Klein almost 11 years ago
- Category set to scheduler
- Status changed from New to Needs Feedback
Updated by David Gurk almost 11 years ago
Good morning Markus,
no, unfortunately not.
If I try this in "typo3_src-6.1.6/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php":
protected function initializeFileStorages() { $this->fileStorages = array(); /** @var $storageRepository \TYPO3\CMS\Core\Resource\StorageRepository */ var_dump('TEST0'); var_dump(\TYPO3\CMS\Core\Utility\GeneralUtility); // \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(\TYPO3\CMS\Core\Utility\GeneralUtility); var_dump('TEST1'); $storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\StorageRepository'); // Admin users have all file storages visible, without any filters if ($this->isAdmin()) { $storageObjects = $storageRepository->findAll(); foreach ($storageObjects as $storageObject) { $this->fileStorages[$storageObject->getUid()] = $storageObject; } } else { // Regular users only have storages that are defined in their filemounts // Permissions and file mounts for the storage are added in StoragePermissionAspect foreach ($this->getFileMountRecords() as $row) { if (!array_key_exists(intval($row['base']), $this->fileStorages)) { $storageObject = $storageRepository->findByUid($row['base']); $this->fileStorages[$storageObject->getUid()] = $storageObject; } } } // This has to be called always in order to set certain filters $this->evaluateUserSpecificFileFilterSettings(); }
And call the CLI-dispathcer in the console I get this:
server:~$ /var/www/foo/bar/htdocs/typo3/cli_dispatch.phpsh scheduler string(5) "TEST0" server:~$
It doesn't matter whether I use "var_dump()" or "\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump()".
"\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump('TEST')" works if it would be use over the line:
$storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\StorageRepository');
I test this at our development-server, where the older TYPO3-Versions-scheduler works. Error reportings in php are available.
But one interessting thing. I let this "debug"-var_dumps at the place and login to the backend I get an error:
string(5) "TEST0" Fatal error: Undefined constant 'TYPO3\CMS\Core\Utility\GeneralUtility' in /var/www/_share/typo3/typo3_src-6.1.6/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php on line 1451 Call Stack: 0.0002 648448 1. {main}() /var/www/_share/typo3/typo3_src-6.1.6/typo3/mod.php:0 0.0002 649016 2. require('/var/www/_share/typo3/typo3_src-6.1.6/typo3/init.php') /var/www/_share/typo3/typo3_src-6.1.6/typo3/mod.php:33 0.0601 8703264 3. TYPO3\CMS\Core\Core\Bootstrap->initializeBackendUserMounts() /var/www/_share/typo3/typo3_src-6.1.6/typo3/init.php:72 0.0601 8703968 4. TYPO3\CMS\Core\Authentication\BackendUserAuthentication->getFileStorages() /var/www/_share/typo3/typo3_src-6.1.6/typo3/sysext/core/Classes/Core/Bootstrap.php:968 0.0601 8703968 5. TYPO3\CMS\Core\Authentication\BackendUserAuthentication->initializeFileStorages() /var/www/_share/typo3/typo3_src-6.1.6/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php:1565
Updated by Philipp Gampe almost 11 years ago
Did you assign any storages to the cli user?
Updated by David Gurk almost 11 years ago
Hi Philipp,
no, I only add a standard user without further configuration.
Updated by David Gurk almost 11 years ago
I try to add a "DB Mount" and a "File Mount" to the user "_cli_scheduler". The problem is still there.
Updated by David Gurk almost 11 years ago
Nobody with an idea? I try to help. But actually I pretty helpless. =)
Updated by David Gurk almost 11 years ago
I try a new, clean TYPO3 v6.1.7 blank-package without any further configuration.
- installed EXT:scheduler
- go to the module "Scheduler"->"Setup Check"
- it shows in red "The backend user "_cli_scheduler" was not found. Create the user now.", so I click on "Create the user now." => no further notes.
- add a "Scheduler test task"
- configure the task. Type = recurring; Start = "now"; End = "empty"; Frequency = */1 * * * *; Allow Parallel Execution = unchecked; Email = "my mail"
- manually start this task => email received
- login with ssh on the server
- a few minutes late - run this command which is shown in Scheduler "Setup Check": /var/www/mypath/t3-blank-6-1/typo3/cli_dispatch.phpsh scheduler
=> Nothing happen. No email will be send.
The task overview shows that this task is late.
The http call over http://my.domain.de/index.php?eID=scheduler_http change nothing too.
Updated by David Gurk almost 11 years ago
Perhaps, this is interesting - here the development-server data:
PHP_VERSION: 5.3.10-1ubuntu3.8
SERVER_SOFTW: Apache/2.2.22
Updated by Alexander Opitz almost 11 years ago
- Status changed from Needs Feedback to New
Updated by David Gurk almost 11 years ago
- Assignee set to Markus Klein
This is still a problem. Am I the only one? =/
For the records: this is not only a scheduler problem, it's a whole CLI dispatcher issue.
Updated by Markus Klein almost 11 years ago
- Category changed from scheduler to Backend User Interface
- Assignee deleted (
Markus Klein)
Sorry David you can't assign somebody here, we're working for free here. ;-)
Do you still get this GeneralUtility error in the errorlog when running the cli task?
Updated by David Gurk almost 11 years ago
- Assignee set to Markus Klein
Sorry, I get it. ^^
You mean this error I explained here at the end of note-3? http://forge.typo3.org/issues/54014#note-3
It's still the same problem. Even in the blank installtion. =/
Updated by Markus Klein almost 11 years ago
- Assignee deleted (
Markus Klein)
This is strange; interpreting TYPO3\CMS\Core\Utility\GeneralUtility as constant!?
Either autoloader problem, or your source code is corrupt.
Please compare the code to http://typo3.org/api/typo3cms/_backend_user_authentication_8php_source.html#l01444
Updated by David Gurk almost 11 years ago
Hmmm strange, the code from your link looks totally different. (Even without comments)
I downloaded the normal core from typo3.org. Particulary:
http://sourceforge.net/projects/typo3/files/TYPO3%20Source%20and%20Dummy/TYPO3%206.1.7/typo3_src-6.1.7.zip/download?use_mirror=garr&download=
/** * Sets up all file storages for a user. * Needs to be called AFTER the groups have been loaded. * * @return void */ protected function initializeFileStorages() { $this->fileStorages = array(); /** @var $storageRepository \TYPO3\CMS\Core\Resource\StorageRepository */ var_dump('TEST1'); \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($storageRepository); $storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\StorageRepository'); \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($storageRepository); var_dump('TEST2'); // Admin users have all file storages visible, without any filters if ($this->isAdmin()) { $storageObjects = $storageRepository->findAll(); foreach ($storageObjects as $storageObject) { $this->fileStorages[$storageObject->getUid()] = $storageObject; } } else { // Regular users only have storages that are defined in their filemounts // Permissions and file mounts for the storage are added in StoragePermissionAspect foreach ($this->getFileMountRecords() as $row) { if (!array_key_exists(intval($row['base']), $this->fileStorages)) { $storageObject = $storageRepository->findByUid($row['base']); $this->fileStorages[$storageObject->getUid()] = $storageObject; } } } // This has to be called always in order to set certain filters $this->evaluateUserSpecificFileFilterSettings(); }
http://typo3.org/api/typo3cms/_backend_user_authentication_8php_source.html#l01444
protected function initializeFileStorages() { $this->fileStorages = array(); $storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\StorageRepository'); // Admin users have all file storages visible, without any filters if ($this->isAdmin()) { $storageObjects = $storageRepository->findAll(); foreach ($storageObjects as $storageObject) { $this->fileStorages[$storageObject->getUid()] = $storageObject; } } else { // If userHomePath is set, we attempt to mount it if ($GLOBALS['TYPO3_CONF_VARS']['BE']['userHomePath']) { list($userHomeStorageUid, $userHomeFilter) = explode(':', $GLOBALS['TYPO3_CONF_VARS']['BE']['userHomePath'], 2); $userHomeStorageUid = intval($userHomeStorageUid); if ($userHomeStorageUid > 0) { $storageObject = $storageRepository->findByUid($userHomeStorageUid); // First try and mount with [uid]_[username] $userHomeFilterIdentifier = $userHomeFilter . $this->user['uid'] . '_' . $this->user['username'] . $GLOBALS['TYPO3_CONF_VARS']['BE']['userUploadDir']; $didMount = $storageObject->addFileMount($userHomeFilterIdentifier); // If that failed, try and mount with only [uid] if (!$didMount) { $userHomeFilterIdentifier = $userHomeFilter . $this->user['uid'] . '_' . $this->user['username'] . $GLOBALS['TYPO3_CONF_VARS']['BE']['userUploadDir']; $storageObject->addFileMount($userHomeFilterIdentifier); } $this->fileStorages[$storageObject->getUid()] = $storageObject; } } // Mount group home-dirs if (($this->user['options'] & 2) == 2 && $GLOBALS['TYPO3_CONF_VARS']['BE']['groupHomePath'] != '') { // If groupHomePath is set, we attempt to mount it list($groupHomeStorageUid, $groupHomeFilter) = explode(':', $GLOBALS['TYPO3_CONF_VARS']['BE']['groupHomePath'], 2); $groupHomeStorageUid = intval($groupHomeStorageUid); if ($groupHomeStorageUid > 0) { $storageObject = $storageRepository->findByUid($groupHomeStorageUid); foreach ($this->userGroups as $groupUid => $groupData) { $groupHomeFilterIdentifier = $groupHomeFilter . $groupData['uid']; $storageObject->addFileMount($groupHomeFilterIdentifier); } $this->fileStorages[$storageObject->getUid()] = $storageObject; } } // Processing filemounts (both from the user and the groups) $this->dataLists['filemount_list'] = \TYPO3\CMS\Core\Utility\GeneralUtility::uniqueList($this->dataLists['filemount_list']); if ($this->dataLists['filemount_list']) { $orderBy = $GLOBALS['TCA']['sys_filemounts']['ctrl']['default_sortby'] ? $GLOBALS['TYPO3_DB']->stripOrderBy($GLOBALS['TCA']['sys_filemounts']['ctrl']['default_sortby']) : 'sorting'; $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_filemounts', 'deleted=0 AND hidden=0 AND pid=0 AND uid IN (' . $this->dataLists['filemount_list'] . ')', '', $orderBy); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $storageObject = $storageRepository->findByUid($row['base']); $storageObject->addFileMount($row['path'], $row); $this->fileStorages[$storageObject->getUid()] = $storageObject; } $GLOBALS['TYPO3_DB']->sql_free_result($res); } } // Injects the users' permissions to each storage foreach ($this->fileStorages as $storageObject) { $storagePermissions = $this->getFilePermissionsForStorage($storageObject); $storageObject->setUserPermissions($storagePermissions); } // more narrowing down through the workspace $this->initializeFileStoragesForWorkspace(); // this has to be called always in order to set certain filters // @todo Should be in BE_USER object then $GLOBALS['BE_USER']->evaluateUserSpecificFileFilterSettings(); }
Replacing "initializeFileStorages" doesn't help.
The "Fatal error: Undefined constant 'TYPO3\CMS\Core\Utility\GeneralUtility'" only appears if I try
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(\TYPO3\CMS\Core\Utility\GeneralUtility);
Updated by Markus Klein almost 11 years ago
You're right api.typo3.org is by far not up to date. Sorry for that. The code has been changed in September 2013 already. ^^
Nevertheless var_dump does not work with classes! So this message is obvious.
Updated by Michal Cygankiewicz over 10 years ago
Did you manage to solve this problem? It seems I have similr problem with 6.2 version...
Updated by David Gurk over 10 years ago
No, sadly not. In 6.1 it's still a problem. But in the newest 6.2 it worked well. I updated a 6.1 to 6.2 and here it worked well too.
Anyone know the different?
Updated by Michal Cygankiewicz over 10 years ago
It's strange but for me it doesn't work on 6.2 becaouse of error:
"Uncaught TYPO3 Exception #1271492607: Database Error: PHP mysqli extension not loaded. This is a must have for TYPO3 CMS!
thrown in file [....]typo3/sysext/core/Classes/Database/DatabaseConnection.php
in line 1168
"
Frontend is working fine, scheduler tasks executed manually are working fine. PHP mysqli extension is loaded, I have tested on PHP 5.4 and 5.5.
Updated by David Gurk over 10 years ago
Um... anyhow, an error is something to work with. Is this this error occurs with any type of scheduler task?
Updated by Michal Cygankiewicz over 10 years ago
It doesn't execute any of the tasks from CLI becaouse it stops before becaouse of this mysqli error...
It stops in typo3\sysext\core\Classes\Authentication\AbstractUserAuthentication.php in function getRawUserByName while trying to execute simple database query ...
"$dbres = $this->db->exec_SELECTquery('*', $this->user_table, 'username=' . $this->db->fullQuoteStr($name, $this->user_table) . ' ' . $this->user_where_clause());"
Updated by David Gurk over 10 years ago
Do you try to test the scheduler with an clean installation of TYPO3 6.2?
Updated by Michal Cygankiewicz over 10 years ago
Thank you for your help. I've solved this issue - in my case the problem was server configuration. CLI-php didn't have mysqli extension loaded and it was the reason why it didn't work - so it was only server configuration problem and not TYPO3 itself.
Updated by David Gurk over 10 years ago
Good to hear. In my case it could be the server configuration (I guess). I run the different TYPO3 DEV Systems on the same machine. 4.7 work, 6.0 and 6.1 don't work and 6.2 work so far.
Updated by Markus Klein over 10 years ago
- Status changed from New to Needs Feedback
Debian-like system have separate configuration for CLI and web. So please check these do match.
Updated by David Gurk over 10 years ago
The DEV Server I mentioned in the last comment is an Ubuntu 12.04.3 LTS. 4.7 and 6.2 work so far.
A customer server (not managed by me) is an Ubuntu 12.04.4 LTS. The TYPO3 6.1 Version have problems with scheduler too.
Updated by David Gurk about 10 years ago
If I only add this to the crontab...
* * * * * /var/www/path/to/server/htdocs/typo3/cli_dispatch.phpsh scheduler
(without /usr/bin/php or anything)
... the scheduler task will executed correctly.
This work for 6.1 and 6.2 equally. I'm not really sure what was wrong in the previous posts, but now I don't have this problem anymore.
In my opinion, this issues can be closed.
Thanks!
Updated by Markus Klein about 10 years ago
- Status changed from Needs Feedback to Closed
Thanks for reporting back.