[wp-trac] [WordPress Trac] #49566: Change comment on `update_blog_option` to properly describe the return value
WordPress Trac
noreply at wordpress.org
Mon Mar 2 21:12:25 UTC 2020
#49566: Change comment on `update_blog_option` to properly describe the return
value
--------------------------------+-----------------------------
Reporter: andfinally | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Options, Meta APIs | Version: trunk
Severity: normal | Keywords: has-patch
Focuses: docs |
--------------------------------+-----------------------------
`update_blog_option` uses `update_option` to set options, and that
function doesn't only return `false` if there's an error: it can also
return `false` if the value of the option hasn't changed.
Reading the comment on `update_blog_option`, you're liable to assume
`false` always means a failure, and make mistakes like:
{{{#!php
if ( false === update_blog_option( 9, 'import_id', 1 ) {
return new WP_Error(
// error data
);
}
}}}
In this situation, every attempt to update an option that already has the
value '1' will be treated as an error.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49566>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list