Opened 8 years ago
Closed 6 years ago
#38301 closed defect (bug) (invalid)
update_network_option not accepting null for network_id
Reported by: | aliakro | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.4 |
Component: | Options, Meta APIs | Keywords: | |
Focuses: | multisite | Cc: |
Description
As per the documentation (https://developer.wordpress.org/reference/functions/update_network_option/) it states:
"(int) (Required) ID of the network. Can be null to default to the current network ID."
However, specifying null returns false.
Looking at the function, It could never get to point to determine the network id itself:
function update_network_option( $network_id, $option, $value ) {
global $wpdb, $current_site;
if ( $network_id && ! is_numeric( $network_id ) ) {
return false;
}
$network_id = (int) $network_id;
// Fallback to the current network if a network ID is not specified.
if ( ! $network_id && is_multisite() ) {
$network_id = $current_site->id;
}
Change History (1)
Note: See
TracTickets for help on using
tickets.
Hi @aliakro,
Thanks for opening this ticket, and welcome to Trac! Sorry that it took so long to receive a response.
I did some testing to confirm. But, the code in
update_network_option()
will work as expected ifnull
is passed.if ( null )
is evaluated asfalse
. Therefor the firstif()
statement in that code block will not evaluate astrue
whennull
is passed.I am going to close this out, but if you are able to trigger incorrect behavior by passing
null
, please reopen and provide some more details.