Skip to content

Return null from Entry::find() for empty ids - #654

Open
daun wants to merge 3 commits into
statamic:5.xfrom
daun:fix/entry-find-null
Open

daun wants to merge 3 commits into
statamic:5.xfrom
daun:fix/entry-find-null

Conversation

@daun

@daun daun commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

EntryRepository::save() caches the entry under its URI:

Blink::put("eloquent-entry-{$entry->uri()}", $entry);

If the entry has no URI yet, the key is eloquent-entry-, which is also what find(null) reads. Entries have no URI yet when they're new in a structured collection. After saving one, Entry::find(null) returns that entry for the rest of the request. Later entries saved without an id are treated as existing: no EntryCreating or EntryCreated events, and no updateEntryOrder() call.

Propagated localizations run into this: in an orderable collection with two sites and propagation on, creating d in one site leaves the other site with the wrong order (d is new and propagates)

fr: a=1 b=2 c=3 d=4
en: a=1 b=2 c=3 d=1

This PR makes find() return null for empty ids without touching Blink, which matches the Stache.

Similar fix in core: statamic/cms#15509.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant