Skip to content

[5.10]: Matrix nested entries saved with postDate = NULL and status pending - regression introduced in #18642 #18872

@john-henry

Description

@john-henry

What happened?

Summary

Since the changes in #18642 (deferred post date auto-assignment), nested entries inside Matrix
fields can be persisted to the database with postDate = NULL, causing them to resolve to
status: pending via the !$this->postDate branch in Entry::_status().

Steps to Reproduce

  1. Create a Matrix field with multiple entry types defined (e.g. "Text Block" and "Image Block").
  2. On a parent entry, add two or more instances of the same entry type (e.g. two "Text Blocks").
  3. Save the parent entry.
  4. Check the entries table — the second (and any additional) nested entry has postDate = NULL
    and an effective status of pending.

Expected Behaviour

All enabled nested entries in a Matrix field receive a postDate on save, consistent with
behaviour before #18642.

Actual Behaviour

The second (and any additional) instance of the same entry type is saved with postDate = NULL
and resolves to status: pending.

Additional Notes

  • The bug does not occur when the Matrix entry type contains only a CKEditor field. This may
    be related to delta tracking — CKEditor likely registers a delta even for a new/empty block,
    while other field types may only register a delta when the user has interacted with them. If the
    second block's fields produce no deltas, Craft may process that entry via a different code path
    that bypasses maybeSetDefaultAttributes().
  • Deleting the affected nested entries and re-adding them does not fix the issue. Craft
    soft-deletes nested entries and the restore path (restoreElements()) uses
    SCENARIO_ESSENTIALS, which also skips maybeSetDefaultAttributes(), so restored entries
    retain their NULL postDate.

Suspected Root Cause

maybeSetDefaultAttributes() in Entry.php is responsible for defaulting postDate to the
current time. Before #18642, this was masked because postDate was pre-seeded to dateCreated
at entry creation. After #18642, postDate starts as null and relies entirely on
maybeSetDefaultAttributes() being reached. For the second instance of a nested entry type in
a multi-type Matrix field, the conditions required to reach the postDate-setting logic are
apparently not met, leaving postDate as null.

Entry::_status() then evaluates null postDate as STATUS_PENDING:

!$this->postDate || $this->postDate > $now => self::STATUS_PENDING,

Reverting the changes from #18642 resolves the issue.

Craft CMS version

5.10.0

PHP version

PHP 8.3

Operating system and version

No response

Database type and version

MySQL

Image driver and version

No response

Installed plugins and versions

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