-
Notifications
You must be signed in to change notification settings - Fork 57
Description
This is as of commit 0e82566 of this repo.
I have a global wp-cli.yml where I have admin user details saved. Also wpd is aliased to the dev version of wp-cli.
To reproduce the issue:
$ which wpd
wpd: aliased to ~/wp-cli/bin/wp
$ mkdir wpcli-multisite && cd wpcli-multisite && wpd core download
Downloading WordPress 4.9.7 (en_US)...
md5 hash verified: 50efc5822bf550e9a526b9b9f4469b0d
Success: WordPress downloaded.
$ wpd core config --dbname="wpclims"
Success: Generated 'wp-config.php' file.
$ wpd db create
Success: Database created.
$ wpd core multisite-install --url="https://wpcms.test" --title="WPCLI Hack"
Created single site database tables.
Set up multisite database tables.
Success: Network installed. Don't forget to set up rewrite rules (and a .htaccess file, if using Apache).
Then opening the database, I see the following:
Why is this a problem?
When using persistent cache (redis), the value of site_admins is empty, and I lose access to the Network Admin dashboard.
If persistent cache is not used, then wp_load_core_site_options loads all important site meta into memory, and caches them one by one in a global. Because site_admins is present twice, the second one overwrites the first, and because the second one is the valid value, it accidentally works.
If persistent cache IS used, wp_load_core_site_options doesn't do anything, and a call to get_super_admins ends up at get_network_option, which retrieves the option the first time it's needed with
$row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $network_id ) );
That one grabs the first row, which is empty, thereby breaking functionality.
