Skip to content
Snippets Groups Projects
Commit 02df7827 authored by Benni Mack's avatar Benni Mack Committed by Wouter Wolters
Browse files

[BUGFIX] Avoid fatal error in scheduler

The scheduler object cleans up execution
arrays on instantiation. Due to the PSR-3
refactoring, the logger is instantiated
after the constructor is called - resulting
in a fatal error ("Call to member function info()
on null") when cleaning up the execution array.

The patch manually instantiates a logger if
there isn't one already.

Resolves: #85148
Releases: master
Change-Id: I5ff3a06a2b9d7e511d5d243df545359a48bf84b1
Reviewed-on: https://review.typo3.org/57118


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarOliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: default avatarJoerg Boesche <typo3@joergboesche.de>
Reviewed-by: default avatarDaniel Gorges <daniel.gorges@b13.de>
Tested-by: default avatarDaniel Gorges <daniel.gorges@b13.de>
Reviewed-by: default avatarSteffen Frese <steffenf14@gmail.com>
Reviewed-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
parent b3283c5e
Branches
No related merge requests found
......@@ -16,10 +16,12 @@ namespace TYPO3\CMS\Scheduler;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use Psr\Log\LoggerInterface;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryHelper;
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\Registry;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -447,6 +449,11 @@ class Scheduler implements SingletonInterface, LoggerAwareInterface
*/
public function log($message, $status = 0, $code = '')
{
// this method could be called from the constructor (via "cleanExecutionArrays") and no logger is instantiated
// by then, that's why check if the logger is available
if (!($this->logger instanceof LoggerInterface)) {
$this->setLogger(GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__));
}
$message = trim('[scheduler]: ' . $code) . ' - ' . $message;
switch ((int)$status) {
// error (user problem)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment