How do I know if an element is published for the first time? #9638
-
DescriptionI used to know this by $event->isNew, but that doesn't work anymore since it already fires at the creation of the first draft. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
This was an unintended casualty of keeping the entry ID consistent between its unpublished draft and the real entry (#9104). Before 3.7, the unpublished draft was duplicated into a normal entry, with a new ID, therefore It’s too late to revert the change, and I don’t think we should set So I just released Craft 3.7.5 with a new |
Beta Was this translation helpful? Give feedback.
-
I've posted some thoughts on matching New and Updated Element scenarios on Stack Exchange which also discusses some considerations like multi-site and resaving elements tasks. With the number of conditions, it may be nice to see an officially supported
Where we could call it doing something like:
|
Beta Was this translation helpful? Give feedback.
This was an unintended casualty of keeping the entry ID consistent between its unpublished draft and the real entry (#9104). Before 3.7, the unpublished draft was duplicated into a normal entry, with a new ID, therefore
$isNew
wastrue
.It’s too late to revert the change, and I don’t think we should set
$isNew = true
for backwards compatibility since it’s not technically true.So I just released Craft 3.7.5 with a new
$firstSave
property on entries. It will betrue
whenever an entry is getting saved for the first time as a normal (non-draft, non-revision) entry. (416479f)