Skip to content

How do I know if an element is published for the first time? #9638

Closed Answered by brandonkelly
boboldehampsink asked this question in Q&A
Discussion options

You must be logged in to vote

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 was true.

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 be true whenever an entry is getting saved for the first time as a normal (non-draft, non-revision) entry. (416479f)

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
3 replies
@brandonkelly
Comment options

@Anubarak
Comment options

@brandonkelly
Comment options

Answer selected by brandonkelly
Comment options

You must be logged in to vote
3 replies
@Anubarak
Comment options

@brandonkelly
Comment options

@BenParizek
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
4 participants
Converted from issue

This discussion was converted from issue #9635 on July 24, 2021 02:39.