Fix duplicate backed enum values in PHP
What the message means
Duplicate value in enum means that two cases in a backed enum have the same underlying value. An enum models a fixed set of choices, such as order states. PHP requires each backed case to have its own value.
This is a conflicting definition, not a missing return declaration or a warning about an inherited method.
Before you change anything
Save the complete error line and its timestamp in a private note. Record the failed action, the active PHP version and any components updated at the same time. Do not post passwords, customer details or full server paths in a public support forum.
Back up both files and the database before making changes. Check that the backup can actually be restored. Use a protected test copy with the same PHP version and relevant settings, with real payments and outgoing customer emails disabled.
Agree who will make the change and who will check the result. Match the log entry to the action you perform on the website. An old background task can produce a message unrelated to the page you are looking at now.
Cause and related errors
A backed enum associates its cases with either string values or integer values. The case names can differ while the underlying values accidentally match. For example, enum OrderState: string { case Pending = "pending"; case Paid = "pending"; } assigns the same string twice.
Evaluating OrderState::from("pending") exposes the conflict. Renaming Paid alone does not change that mapping.
Look for a copied case definition or an extension that introduced another status. Compare the definition with the values already stored in the database and exchanged with other services. A distinct label on the screen does not establish a distinct stored value.
Keep the technical error separate from a business decision about which states should exist.
Five steps to repair
- Save the complete error and the enum name. Reproduce the failed action on the test copy and identify which component defines that enum.
- Compare all case values, not just their names. Mark the conflicting pair and check which values the database and connected systems currently use.
- Agree the intended mapping with the component owner. Give genuinely different states unique values, or use an enum constant as an alias when one existing case is intended.
- Test both the repaired definition and the conversion of existing stored values. Check the displayed state and any action triggered by that state.
- Repeat the original request and inspect fresh logs. Release only after the expected state and saved record agree, with a rollback plan for any separately approved data migration.
A concrete acceptance test
Use a small local fixture with Pending = "pending" and Paid = "pending" to reproduce the problem. In a corrected fixture, use Pending = "pending" and Paid = "paid". Confirm that OrderState::from("pending") identifies Pending and OrderState::from("paid") identifies Paid.
These are test values, not instructions to rewrite live orders.
Add a case that loads a record created before the repair. It must keep its intended meaning. If old data cannot distinguish pending from paid, changing the enum definition cannot recover that missing information.
Escalate that ambiguity to the data owner instead of guessing. Record the mapping decision beside the regression test so that a future case does not reuse an existing value.
Updating WordPress or WooCommerce components
If the error points to a plugin or theme, first check whether its author documents a relevant update. Record the installed version before trying that update on the test copy. Include any custom extensions that depend on the component in your checks.
Avoid editing supplier files without an agreed maintenance plan. A later update can overwrite a manual repair. For custom code, ask for a change that is kept with the source code and can be tested again during the next PHP update.
When to ask for help
Use the existing PHP update service if you cannot trace the error or if it affects orders, payments or saved records. Describe the failed action and the expected result in the help form below. An error message alone does not identify which component needs to change.
Ask the maintainer to record the cause and proposed repair first. After the change, repeat the original action and inspect fresh log entries at the test timestamp. For a store, also inspect the saved test order without taking a real payment.
Check your PHP version
Use the Exposure Check link below this article to check your PHP version where it is publicly visible. If that information is unavailable, ask your host to confirm the active version. This check cannot read private logs and does not prove that the programming error is fixed.
Visit the PHP security status page for the separate assessment of your PHP version. Save the versions, code change and test outcome in your maintenance notes. Let the responsible maintainer decide when the tested repair should be applied to the live website.