Commit 213355eb80 for wordpress.org

commit 213355eb803ce19fe4b49d4fcd13735665a68d8e
Author: Peter Wilson <wilson@peterwilson.cc>
Date:   Thu Jul 25 23:04:12 2024 +0000

    Options, Meta APIs: Prevent Single Site installs using network notoptions cache.

    Modifies the caching of `notoptions` in `delete_network_option()` to ensure that the network cache is bypassed on single site installs.

    On single site installs the incorrect caching was causing the `notoptions` cache to remain populated once a deleted option was subsequently added or updated.

    Follow up to [58782].

    Props bjorsch, pbearne.
    Fixes #61730.
    See #61484.


    Built from https://develop.svn.wordpress.org/trunk@58811


    git-svn-id: http://core.svn.wordpress.org/trunk@58207 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-includes/option.php b/wp-includes/option.php
index 125f25d40d..537f7aafd0 100644
--- a/wp-includes/option.php
+++ b/wp-includes/option.php
@@ -2264,6 +2264,17 @@ function delete_network_option( $network_id, $option ) {
 				'site_id'  => $network_id,
 			)
 		);
+
+		if ( $result ) {
+			$notoptions_key = "$network_id:notoptions";
+			$notoptions     = wp_cache_get( $notoptions_key, 'site-options' );
+
+			if ( ! is_array( $notoptions ) ) {
+				$notoptions = array();
+			}
+			$notoptions[ $option ] = true;
+			wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
+		}
 	}

 	if ( $result ) {
@@ -2293,15 +2304,6 @@ function delete_network_option( $network_id, $option ) {
 		 */
 		do_action( 'delete_site_option', $option, $network_id );

-		$notoptions_key = "$network_id:notoptions";
-		$notoptions     = wp_cache_get( $notoptions_key, 'site-options' );
-
-		if ( ! is_array( $notoptions ) ) {
-			$notoptions = array();
-		}
-		$notoptions[ $option ] = true;
-		wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
-
 		return true;
 	}

diff --git a/wp-includes/version.php b/wp-includes/version.php
index 0bb154cc04..c28e9d35db 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '6.7-alpha-58810';
+$wp_version = '6.7-alpha-58811';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.