Make WordPress Core

Opened 10 years ago

Closed 8 years ago

#38301 closed defect (bug) (invalid)

update_network_option not accepting null for network_id

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

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)

#1 @desrosj
8 years ago

  • Component General → Options, Meta APIs
  • Focuses multisite added
  • Milestone Awaiting Review
  • Resolution → invalid
  • Status new → closed
  • Version 4.6.1 → 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.