[wp-trac] [WordPress Trac] #63797: Unexpected short‑circuit return values from add_metadata() and update_metadata()
WordPress Trac
noreply at wordpress.org
Thu Aug 7 23:56:22 UTC 2025
#63797: Unexpected short‑circuit return values from add_metadata() and
update_metadata()
--------------------------------+------------------------------
Reporter: marian1 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Options, Meta APIs | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------------+------------------------------
Comment (by peterwilsoncc):
The filters system in WordPress is really powerful, this can be both an
advantage and a disadvantage as developers can make mistakes.
It's not possible to change the return value in each of these cases to
`false` as it assumes developers are using the pre-flight filters
exclusively to prevent the insertion of meta data. In some cases, plugins
use the filter to move the meta data to custom meta tables and do need to
return the ID of the inserted row, see
[https://plugins.trac.wordpress.org/browser/easy-digital-
downloads/tags/3.3.6.1/src/Compat/Discount.php?marks=333-552#L333 EDD's
back-compat code] for an example.
@abcd95 I'm hesitant to throw a _doing_it_wrong as in that example for a
couple of reasons:
* it suggests the error is with the WP function rather than a developers
filter, the error message would need to reference the function returning
the incorrect value and if multiple filters are added to the hook, it's
not possible to know which is causing the error
* it also adds logs to the end-user's site when they may not be able to
take action to recover from the error
That said, I'd like to think about it further and consider ways to
implement it so developers who do make an error are informed. I'll seek
some input from others.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63797#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list