Skip to content

Serialization error with PHP 8.x after adding @Lazy annotations in 12.5.4 #1318

@wrock

Description

@wrock

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

  1. Create a Powermail form with fields
  2. Add the form to a page
  3. Enable page caching (or use USER_INT content on the page)
  4. 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:

  1. Page caching / serialization
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions