Opened 13 years ago
Closed 10 years ago
#22846 closed defect (bug) (fixed)
Site transient autoload even when they have expiry time
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.6 | Priority: | normal |
| Severity: | normal | Version: | 2.9 |
| Component: | Options, Meta APIs | Keywords: | has-patch has-unit-tests |
| Focuses: | multisite, performance | Cc: |
Description
I guess set_site_transient should set autoload to NO after calling add_site_option when there is expiration time.
As far as I can see the all of the site transients right now are used only by cron and admin so no reason to auto load
Attachments (3)
Change History (16)
#4
@
11 years ago
This problem still exists in 3.9.1.
I was researching why BruteProtect's (http://wordpress.org/plugins/bruteprotect) transients were set to auto-load - a potentially serious performance issue, given the nature of that plugin (one transient created per IP address trying to log in).
#6
in reply to:
↑ description
;
follow-up:
↓ 7
@
10 years ago
Replying to mark-k:
I guess set_site_transient should set autoload to NO after calling add_site_option when there is expiration time.
add_site_option does not have an "autoload" parameter. Moreover, the sitemeta table, where site options and site transients are stored, does not have a column called "autoload".
Autoloading of network options happens in wp_load_core_site_options(), but there's a hardcoded list of options which are autoloaded.
$core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' );
$core_options_in = "'" . implode("', '", $core_options) . "'";
$options = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) );
So, WordPress does not autoload site transients.
#7
in reply to:
↑ 6
@
10 years ago
Replying to thomaswm:
So, WordPress does not autoload site transients.
I think you mean "A WordPress multisite install does not autoload site transients". Non-multisite installs do, which is what this bug is about.
#8
follow-up:
↓ 9
@
10 years ago
- Keywords needs-unit-tests added
- Milestone changed from Awaiting Review to Future Release
This doesn't just impact site transients, but any use of add/update_site_option that expects to fallback to add/update_option option in a single site environment.
We could probably add the autoload parameter to _network_option() and _site_option(), though as mentioned, there is no concept of autoload in $wpdb->sitemeta. We would need to make it clear that the parameter is only used in fallback situations. Is that worth it?
A slightly more weird route (IMO) would be to add the concept of auto loading site meta. wp_load_core_site_options() would then pull from a more dynamic list. I'd hesitate to go here though.
Related: the autoload parameter was added to update_option() in 4.2, #26394.
#9
in reply to:
↑ 8
;
follow-up:
↓ 10
@
10 years ago
- Keywords has-patch needs-testing added; needs-patch removed
Replying to jeremyfelt:
We could probably add the autoload parameter to
_network_option()and_site_option(), though as mentioned, there is no concept of autoload in$wpdb->sitemeta.
Alternatively, the code in add_network_option() could be changed so that in single-site installations, it falls back to add_option(), but it sets the $autoload parameter to 'no'. That way, single-site and multisite installations would show the same behaviour. They both wouldn't autoload network options (and transients).
See 22846.2.diff
#10
in reply to:
↑ 9
@
10 years ago
- Keywords needs-unit-tests needs-testing removed
- Milestone changed from Future Release to 4.6
- Owner set to jeremyfelt
- Status changed from new to reviewing
Replying to thomaswm:
Alternatively, the code in
add_network_option()could be changed so that in single-site installations, it falls back toadd_option(), but it sets the$autoloadparameter to 'no'. That way, single-site and multisite installations would show the same behaviour. They both wouldn't autoload network options (and transients).
+1 Much easier. :)
#11
@
10 years ago
- Keywords has-unit-tests added
22846.3.diff adds tests for set_site_transient(), update_network_option(), and add_network_option() to confirm 22846.2.diff
Problem still exists in 3.5.1, meaning all site transients are autoloaded on every page on every site. This includes such broadly useful things as the 'browser_' site transients (only used by wp_check_browser_version() in the dashboard).