Bug #87715
Updated by Ralf Zimmermann almost 6 years ago
The task objects from the scheduler are serialized and persisted within th Database (tx_scheduler_task.serialized_task_object). Therefore the logger configuration is serialized too. Since https://github.com/TYPO3/TYPO3.CMS/commit/233e876814cfc82e99dc2067c7a59a21e84eec9c#diff-24fabbaa634df3c357cb233b8f0cc0ef there is an __wakeup() implementation which restores the FileWriter::class `logFile` property on deserialization. If this happens on another TYPO3 instance (e.g. a testing system) and the logFile path is not writable an exception occurs and the scheduler module is inaccessible. Steps to reproduce * use the default writerConfiguration `$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'] => [\TYPO3\CMS\Core\Log\LogLevel::WARNING => [\TYPO3\CMS\Core\Log\Writer\FileWriter::class => []]];` on both instances * create a scheduler task on a TYPO3 instance A (e.g. the production server) * dump the database and import it within another TYPO3 instance B (e.g. the dev server) * the log directory from the Server A (e.g. /remote/server/var/log/) /remote/server/public/var/log/) must be different to the log directory from Server B (e.g /local/foo/bar/var/log/) /local/foo/bar/public/var/log/) * the log path from Server A must be not writable on server B * open the scheduler module Stacktrace: <pre> (1/1) #1170251401 RuntimeException Could not create directory "/remote/server/var/log/"! "/remote/server/public/var/log/"! in /local/foo/bar/public/typo3/sysext/core/Classes/Utility/GeneralUtility.php line 2172 if (!$result && !@is_dir($fullDirectoryPath)) { throw new \RuntimeException('Could not create directory "' . $fullDirectoryPath . '"!', 1170251401); } at TYPO3\CMS\Core\Utility\GeneralUtility::createDirectoryPath('/remote/server/var/log/') TYPO3\CMS\Core\Utility\GeneralUtility::createDirectoryPath('/remote/server/public/var/log/') in /local/foo/bar/public/typo3/sysext/core/Classes/Utility/GeneralUtility.php line 2140 $firstCreatedPath = static::createDirectoryPath($fullPath); at TYPO3\CMS\Core\Utility\GeneralUtility::mkdir_deep('/remote/server/path/var/log') in /local/foo/bar/public/typo3/sysext/core/Classes/Log/Writer/FileWriter.php line 222 GeneralUtility::mkdir_deep($logFileDirectory); at TYPO3\CMS\Core\Log\Writer\FileWriter->createLogFile() in /local/foo/bar/public/typo3/sysext/core/Classes/Log/Writer/FileWriter.php line 193 $this->createLogFile(); at TYPO3\CMS\Core\Log\Writer\FileWriter->openLogFile() in /local/foo/bar/public/typo3/sysext/core/Classes/Log/Writer/FileWriter.php line 123 $this->openLogFile(); at TYPO3\CMS\Core\Log\Writer\FileWriter->setLogFile('/remote/server/var/log/typo3_122eb88a41.log') TYPO3\CMS\Core\Log\Writer\FileWriter->setLogFile('/remote/server/public/var/log/typo3_122eb88a41.log') in /local/foo/bar/public/typo3/sysext/core/Classes/Log/Writer/FileWriter.php line 281 public function __wakeup() { self::$logFileHandlesCount[$this->logFile]++; $this->setLogFile($this->logFile ?: $this->getDefaultLogFileName()); } at TYPO3\CMS\Core\Log\Writer\FileWriter->__wakeup() at unserialize('O:32:"TYPO3\\CMS\\Extbase\\Scheduler\\Task":11:{s:20:"' . "\0" . '*' . "\0" . 'commandIdentifier";s:11:"foo:bar:baz";s:12:"' . "\0" . '*' . "\0" . 'arguments";a:0:{}s:11:"' . "\0" . '*' . "\0" . 'defaults";a:1:{s:10:"parameters";N;}s:10:"' . "\0" . '*' . "\0" . 'taskUid";i:7;s:11:"' . "\0" . '*' . "\0" . 'disabled";b:0;s:19:"' . "\0" . '*' . "\0" . 'runOnNextCronJob";b:0;s:12:"' . "\0" . '*' . "\0" . 'execution";O:29:"TYPO3\\CMS\\Scheduler\\Execution":6:{s:8:"' . "\0" . '*' . "\0" . 'start";i:1550064925;s:6:"' . "\0" . '*' . "\0" . 'end";s:0:"";s:11:"' . "\0" . '*' . "\0" . 'interval";i:0;s:11:"' . "\0" . '*' . "\0" . 'multiple";s:1:"0";s:10:"' . "\0" . '*' . "\0" . 'cronCmd";s:11:"0 */2 * * *";s:23:"' . "\0" . '*' . "\0" . 'isNewSingleExecution";b:0;}s:16:"' . "\0" . '*' . "\0" . 'executionTime";i:1550070000;s:14:"' . "\0" . '*' . "\0" . 'description";s:3:"Foo";s:12:"' . "\0" . '*' . "\0" . 'taskGroup";i:0;s:9:"' . "\0" . '*' . "\0" . 'logger";O:25:"TYPO3\\CMS\\Core\\Log\\Logger":5:{s:7:"' . "\0" . '*' . "\0" . 'name";s:32:"TYPO3.CMS.Extbase.Scheduler.Task";s:12:"' . "\0" . '*' . "\0" . 'requestId";s:13:"0a455535e8241";s:18:"' . "\0" . '*' . "\0" . 'minimumLogLevel";i:7;s:10:"' . "\0" . '*' . "\0" . 'writers";a:8:{i:0;a:2:{i:0;O:36:"TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter":1:{s:10:"' . "\0" . '*' . "\0" . 'logFile";s:43:"/remote/server/var/log/typo3_122eb88a41.log";}i:1;O:42:"TYPO3\\CMS\\Adminpanel\\Log\\InMemoryLogWriter":0:{}}i:1;a:2:{i:0;r:25;i:1;r:27;}i:2;a:2:{i:0;r:25;i:1;r:27;}i:3;a:2:{i:0;r:25;i:1;r:27;}i:4;a:2:{i:0;r:25;i:1;r:27;}i:5;a:1:{i:0;r:27;}i:6;a:1:{i:0;r:27;}i:7;a:1:{i:0;r:27;}}s:13:"' 'logFile";s:50:"/remote/server/public/var/log/typo3_122eb88a41.log";}i:1;O:42:"TYPO3\\CMS\\Adminpanel\\Log\\InMemoryLogWriter":0:{}}i:1;a:2:{i:0;r:25;i:1;r:27;}i:2;a:2:{i:0;r:25;i:1;r:27;}i:3;a:2:{i:0;r:25;i:1;r:27;}i:4;a:2:{i:0;r:25;i:1;r:27;}i:5;a:1:{i:0;r:27;}i:6;a:1:{i:0;r:27;}i:7;a:1:{i:0;r:27;}}s:13:"' . "\0" . '*' . "\0" . 'processors";a:0:{}}}') in /local/foo/bar/public/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php line 906 $task = unserialize($schedulerRecord['serialized_task_object']); </pre>