8

I installed Wordpress 4.0.1 and added this to my wp-config.php (via this link)

define( 'WP_AUTO_UPDATE_CORE', true );

I then visited my site (I read somewhere before that the site has to be visited to trigger the auto update)...but hours later and nothing has happened (my site has not auto updated to 4.1.1).

I cannot find any information on what triggers/causes Wordpress to auto update (and cannot find the bookmark I had of where I read that visiting the site is part of it).

Does anyone know and/or can point me to some hard data of how to/what triggers Wordpress to auto update?

6
  • 1
    IIRC, auto updates only happen for minor version updates (eg, 4.1 » 4.1.1). For major updates, like the one you're trying to do, you still need to go to the update page. If you want something that you can schedule (eg, with cron or something equivalent), you should look into WP-CLI.
    – Pat J
    Apr 4, 2015 at 3:47
  • ...reading Configuring Automatic Background Updates, it appears I'm wrong about the minor-version thing.
    – Pat J
    Apr 4, 2015 at 3:50
  • Yes, that's what is confusing me. It should be doing major updates too.
    – codeview
    Apr 4, 2015 at 4:13
  • Read this too: The definitive guide to disabling auto updates in WordPress 3.7 – note the bit about how if you have a version control (.svn, .git, .hg, .bzr) auto updates will be disabled. Apr 4, 2015 at 11:51
  • @williamt - thanks for the link. But I am not using version control. I installed and ran the Background Update Tester plugin he mentions in the article and my site passes on all 4 checks (so it should be auto updating). The article also says "...inside the first 12 hours. (That’s how often installs check WordPress.org to see if there is a pending update.)". But I'm well over 12 hours and still no auto-update to 4.1
    – codeview
    Apr 4, 2015 at 17:20

1 Answer 1

12

As of Wordpress 4.7.3, auto-updates are triggered whenever the following sequence is successful. All the code is in the file wp-includes/update.php.

1. _maybe_update_core() is called (via the admin_init action).

This function is run via the the admin_init action, which executes at the beginning of every admin page before the page is rendered. The update process stops if the current time is less than 12 hours since the last version check (using Transient data), unless the version of the current wordpress has changed (e.g., if Wordpress was manually updated since the last time a auto-update ran).

function _maybe_update_core() {
    // include an unmodified $wp_version
    include( ABSPATH . WPINC . '/version.php' );

    $current = get_site_transient( 'update_core' );

    if ( isset( $current->last_checked, $current->version_checked ) &&
        12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) &&
        $current->version_checked == $wp_version ) {
        return;
    }
    wp_version_check();
}

2. wp_version_check() is run and checks for a new version, and decides if doing auto-update is appropriate.

This function is mainly used to ensure version checks don't run too frequently (max once per minute) and retrieve the version info from the api.wordpress.org version-check API. However, at the very end of the function, updates will be run if the request that triggered the update was done via a CRON task and an auto-update is not currently in process:

if ( defined( 'DOING_CRON' ) && DOING_CRON && ! doing_action( 'wp_maybe_auto_update' ) ) {
    do_action( 'wp_maybe_auto_update' );
}

3. wp_maybe_auto_update() then does the actual upgrade.

function wp_maybe_auto_update() {
    include_once( ABSPATH . '/wp-admin/includes/admin.php' );
    include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' );

    $upgrader = new WP_Automatic_Updater;
    $upgrader->run();
}

Here is a tip how to force an auto-update manually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.