[wp-trac] [WordPress Trac] #27199: When site_name is missing from sitemeta table, it cannot be updated by Network > Settings screen
WordPress Trac
noreply at wordpress.org
Tue Feb 25 01:03:59 UTC 2014
#27199: When site_name is missing from sitemeta table, it cannot be updated by
Network > Settings screen
--------------------------------+-----------------------------
Reporter: JPry | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Options, Meta APIs | Version: trunk
Severity: normal | Keywords:
Focuses: multisite |
--------------------------------+-----------------------------
While it is uncommon, if the `site_name` meta_key is missing from the
`sitemeta` table, it is not possible to update the `site_name` key using
the Network Admin > Settings page. This is because a default value (the
domain name) is set and cached.
This may be related to #16676, although I don't believe that change set
introduced the problem.
Steps to reproduce:
1. Set up WordPress Multisite.
2. In the database, remove the `site_name` meta_key from the sitemeta
table:
{{{
DELETE FROM `wp_sitemeta` WHERE `meta_key` = 'site_name';
}}}
3. Go to the WordPress Dashboard, and navigate to Network Admin > Settings
4. Change the value for "Network Title"
5. Click the "Save Changes" button
When the page reloads, you will see that the Network Title has not been
updated. You can confirm in the database that the `site_name` key has not
been added back to the `sitemeta` table.
Here's what I believe is happening inside WordPress that causes this
behavior:
1. `ms-settings.php` calls the `get_current_site_name()` function. In
3.8.1 this is at line 112.
2. `get_current_site_name()` attempts to determine the current site name
(obviously). In doing that, it first checks the cache. If there's no
cached value, it checks the `sitemeta` table. Finally, if there's no
matching value in the `sitemeta` table, it defaults to the domain name of
the network.
3. Regardless of how the current site name was derived in step 2 above,
the value is cached.
4. When updating the `site_name` option, `update_site_option()` is called
first.
5. `update_site_option()` uses `get_site_option()` to determine the
current value of the option, for comparison purposes.
6. `get_site_option()` is allowed to use cache, and so it retrieves the
cached value that was set inside `get_current_site_name()`
7. `update_site_option()` has a value to use for comparison: the domain
name of the site. Unfortunately, that value is '''not''' `false`. This
means that `update_site_option()` will attempt to update the database
instead of adding a new option.
8. `update_site_option()` fails (returning a value of `false`) because
nothing was updated, due to the fact that the value is not present in the
database.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27199>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list