Summary
Version 12.5.4 introduced @Lazy annotations in PR #1246 to fix a memory leak. However, this change breaks page caching with PHP 8.x due to strict type enforcement during unserialization.
TYPO3 / PHP Version
- TYPO3: 12.4.39
- PHP: 8.1.33
- Powermail: 12.5.4 (works with 12.5.3)
Steps to Reproduce
- Create a Powermail form with fields
- Add the form to a page
- Enable page caching (or use USER_INT content on the page)
- Visit the page
Expected Behavior
The page renders correctly with the Powermail form.
Actual Behavior
500 error with TypeError:
Cannot assign null to property TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject::$_cleanProperties of type array
Full stack trace:
#0 /var/www/html/vendor/typo3/cms-frontend/Classes/Controller/TypoScriptFrontendController.php(2296): unserialize()
Root Cause Analysis
PR #1246 added @TYPO3\CMS\Extbase\Annotation\ORM\Lazy to:
Classes/Domain/Model/Form.php → $pages property
Classes/Domain/Model/Page.php → $fields property
When Powermail domain objects (Form → Page → Field) are serialized for caching, the LazyLoadingProxy objects don't serialize properly. During unserialization, the _cleanProperties property (typed as array in AbstractDomainObject) receives null instead of an empty array.
PHP 8.x strict typing then throws the TypeError because null cannot be assigned to a property typed as array.
Workaround
Downgrade to Powermail 12.5.3:
Suggested Fix
The @Lazy annotation approach needs to be reconsidered for compatibility with:
- Page caching / serialization
- PHP 8.x strict typing
Possible solutions:
- Implement
__sleep() and __wakeup() methods to handle serialization properly
- Use a different approach to prevent the memory leak that doesn't involve lazy loading on these specific properties
- Ensure
_cleanProperties is initialized as empty array [] after unserialization
Related
Summary
Version 12.5.4 introduced
@Lazyannotations in PR #1246 to fix a memory leak. However, this change breaks page caching with PHP 8.x due to strict type enforcement during unserialization.TYPO3 / PHP Version
Steps to Reproduce
Expected Behavior
The page renders correctly with the Powermail form.
Actual Behavior
500 error with TypeError:
Full stack trace:
Root Cause Analysis
PR #1246 added
@TYPO3\CMS\Extbase\Annotation\ORM\Lazyto:Classes/Domain/Model/Form.php→$pagespropertyClasses/Domain/Model/Page.php→$fieldspropertyWhen Powermail domain objects (Form → Page → Field) are serialized for caching, the
LazyLoadingProxyobjects don't serialize properly. During unserialization, the_cleanPropertiesproperty (typed asarrayinAbstractDomainObject) receivesnullinstead of an empty array.PHP 8.x strict typing then throws the TypeError because
nullcannot be assigned to a property typed asarray.Workaround
Downgrade to Powermail 12.5.3:
Suggested Fix
The
@Lazyannotation approach needs to be reconsidered for compatibility with:Possible solutions:
__sleep()and__wakeup()methods to handle serialization properly_cleanPropertiesis initialized as empty array[]after unserializationRelated