Duncan McClean

How to resolve Duplicate IDs in Statamic 3

Published 6 months ago

It happens quite often, you might delete or rename something in production, and at some point in the future push up your new entries and somewhere there's a duplicate ID.

In Statamic 2, there used to be a really simple way of resolving conflicting IDs. They would pop up in the Control Panel and there'd be a button to help you resolve them. Real simple.

But in Statamic 3, it's not so simple anymore. In fact, Statamic won't directly tell you that you have duplicate IDs, it'll just give you an error message:

Call to a member function id() on null" at statamic/cms/src/Stache/Stores/Store.php(70)

There's a couple of issues that cause that error message but more often than not it's to do with duplicates.

I've written a little Artisan command you can run to identify any duplicate entries/taxonomies etc and even resolve them if you want. It's over on Github Gists.

Hopefully that little script will help someone out.