Make WordPress Core

Opened 8 years ago

Closed 5 years ago

#38301 closed defect (bug) (invalid)

update_network_option not accepting null for network_id

Reported by: aliakro's profile aliakro Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4
Component: Options, Meta APIs Keywords:
Focuses: multisite Cc:


As per the documentation ( 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)

#1 @desrosj
5 years ago

  • Component changed from General to Options, Meta APIs
  • Focuses multisite added
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
  • Version changed from 4.6.1 to 4.4

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 if null is passed. if ( null ) is evaluated as false. Therefor the first if() statement in that code block will not evaluate as true when null 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.

Note: See TracTickets for help on using tickets.