[wp-trac] [WordPress Trac] #31011: WP 4.1 checks for updates with every load of any admin page
WordPress Trac
noreply at wordpress.org
Thu Jan 29 23:38:33 UTC 2015
#31011: WP 4.1 checks for updates with every load of any admin page
-------------------------------------+--------------------
Reporter: hallcp | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.1.1
Component: Administration | Version: 4.1
Severity: normal | Resolution:
Keywords: has-patch needs-testing | Focuses:
-------------------------------------+--------------------
Changes (by SergeyBiryukov):
* keywords: reporter-feedback has-patch needs-testing => has-patch needs-
testing
* milestone: Awaiting Review => 4.1.1
Comment:
Replying to [comment:4 craig0990]:
> Every time I load the WordPress 4.1 admin, I see:
>
> {{{
> Warning: An unexpected error occurred. Something may be wrong with
WordPress.org or this server’s configuration. If you continue to have
problems, please try the support forums. (WordPress could not establish a
secure connection to WordPress.org. Please contact your server
administrator.) in /var/www/cgr/admin/httpdocs/wp-includes/update.php on
line 295
> }}}
Seeing a lot of similar reports on support forums.
> Like ''hallcp'', the API call to check for updates is timing out. I
suspect this is why it runs on every single page load - if it never
''succeeds'', then it never resets the timer.
Correct.
> The culprit appears to be in the wp_get_update_data() function where two
update calls were added in 4.1
Introduced in [30696].
To reproduce the issue, just set `WP_HTTP_BLOCK_EXTERNAL` to true and
clear the `'update_plugins'` and `'update_themes'` transients.
On each admin page load, we check if any [source:tags/4.1/src/wp-
includes/update.php#L228 plugins] or [source:tags/4.1/src/wp-
includes/update.php#L393 themes] changed since the last request. If they
did, or if the last request never succeeded (`$current->checked` is
empty), the 12-hour timeout is discarded, and we're making another
request, which fails as well, leading to yet another request on next page
load, etc.
So, [30696] didn't introduce any new issues for sites that don't have any
troubles connecting to WordPress.org, but it made the situation much worse
for those that do have troubles.
As a workaround, this should short-circuit the requests and prevent them
from being run on each admin page load:
{{{
function override_updated_plugins_check_31011( $transient ) {
$plugins = get_plugins();
// Reset the timeout if previous requests never succeeded
if ( ! isset( $transient->checked ) ) {
$last_update->last_checked = time();
}
// Short-circuit the check for changed plugins
foreach ( $plugins as $file => $plugin ) {
if ( ! isset( $transient->checked[ $file ] ) ) {
$transient->checked[ $file ] = $plugin['Version'];
}
}
return $transient;
}
add_filter( 'site_transient_update_plugins',
'override_updated_plugins_check_31011' );
function override_updated_themes_check_31011( $transient ) {
$themes = wp_get_themes();
// Reset the timeout if previous requests never succeeded
if ( ! isset( $transient->checked ) ) {
$last_update->last_checked = time();
}
// Short-circuit the check for changed themes
foreach ( $themes as $theme ) {
$stylesheet = $theme->get_stylesheet();
if ( ! isset( $transient->checked[ $stylesheet ] ) ) {
$transient->checked[ $stylesheet ] = $theme->get(
'Version' );
}
}
return $transient;
}
add_filter( 'site_transient_update_themes',
'override_updated_themes_check_31011' );
}}}
I'd suggest reverting [30696] for 4.1.1 and trying to come up with a
better solution in 4.2.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31011#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list