Project

General

Profile

Actions

Bug #85245

closed

FileWriter instance throws error if used in serialized/unserialized objects

Added by Susanne Moog almost 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
-
Target version:
Start date:
2018-06-12
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

How to reproduce:

- Current master
- Add the following config to AdditionalConfiguration:

$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'] = [
    \TYPO3\CMS\Core\Log\LogLevel::DEBUG => [
        \TYPO3\CMS\Core\Log\Writer\FileWriter::class => [
            'logFile' => 'typo3temp/var/logs/debug.log',
        ],
    ],
];

- Open the scheduler
- Create a new task, add a frequency, try to save
--> fwrite expects parameter to be resource, null given

Background:

- The LogManager instanciates logger instances per class name and GeneralUtility::makeInstance injects these via loggerAwareInterface (or they are fetched via the LogManager directly).
- When constructed, the FileWriter will call "openLogFile" and store the created file handle (fopen...) in a static member variable to share between instances
- The __destruct method closes that file handle
- On serialization / sleep / wake-up static vars aren't resetted, if there was a destruct call before wake-up happens, the file handle may be unset even though it is still needed
- If multiple instances use the same file handle, the handle should only be closed if the last of the instances is destructed (see test in patch)
- The bug appears only now, because with the logging in extbase signalSlotDispatcher the core first uses a logger in a context a) frequently used and b) serialized
- The fix only fixes the FileWriter part, a second issue is the general handling of serialized LoggerAware objects, as these - independent of the configured writer - serialize their configuration, too, which might change in between serialization and unserialization

Actions #1

Updated by Gerrit Code Review almost 6 years ago

  • Status changed from New to Under Review

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/57204

Actions #2

Updated by Susanne Moog almost 6 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #3

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF