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
- Create a Matrix field with multiple entry types defined (e.g. "Text Block" and "Image Block").
- On a parent entry, add two or more instances of the same entry type (e.g. two "Text Blocks").
- Save the parent entry.
- 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
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 tostatus: pendingvia the!$this->postDatebranch inEntry::_status().Steps to Reproduce
entriestable — the second (and any additional) nested entry haspostDate = NULLand an effective status of
pending.Expected Behaviour
All enabled nested entries in a Matrix field receive a
postDateon save, consistent withbehaviour before #18642.
Actual Behaviour
The second (and any additional) instance of the same entry type is saved with
postDate = NULLand resolves to
status: pending.Additional Notes
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().soft-deletes nested entries and the restore path (
restoreElements()) usesSCENARIO_ESSENTIALS, which also skipsmaybeSetDefaultAttributes(), so restored entriesretain their
NULLpostDate.Suspected Root Cause
maybeSetDefaultAttributes()inEntry.phpis responsible for defaultingpostDateto thecurrent time. Before #18642, this was masked because
postDatewas pre-seeded todateCreatedat entry creation. After #18642,
postDatestarts asnulland relies entirely onmaybeSetDefaultAttributes()being reached. For the second instance of a nested entry type ina multi-type Matrix field, the conditions required to reach the postDate-setting logic are
apparently not met, leaving
postDateasnull.Entry::_status()then evaluatesnullpostDate asSTATUS_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