WordPress.org

Ready to get started?Download WordPress

Forums

Disable All WordPress Updates
[resolved] [PATCH] Incorrect disabling of updates (2 posts)

  1. flynsarmy
    Member
    Posted 8 months ago #

    This plugin doesn't actually disable updates but causes them to update on EVERY page load. It's the reason this user is experiencing the issues they are. I'll explain why.

    Take wp_version_check() for example In /wp-includes/update.php. Here is a sample of code:

    $current = get_site_transient( 'update_core' );
    $translations = wp_get_installed_translations( 'core' );
    
    if ( ! is_object($current) ) {
    	$current = new stdClass;
    	$current->updates = array();
    	$current->version_checked = $wp_version;
    }
    
    // Wait 60 seconds between multiple version check requests
    $timeout = 60;
    $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
    if ( $time_not_changed && empty( $extra_stats ) )
    	return false;

    Now look at the filters you provide in your plugin:

    add_filter( 'pre_transient_update_core', create_function( '$a', "return null;" ) );
    add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );

    You're returning null which would result in an update check occurring on EVERY page load. Instead you want the following:

    function __construct() {
    	add_action('admin_init', array(&$this, 'admin_init'));
    
    	/*
    	 * Disable Theme Updates
    	 * 2.8 to 3.0
    	 */
    	add_filter( 'pre_transient_update_themes', array($this, 'last_checked_now') );
    	/*
    	 * 3.0
    	 */
    	add_filter( 'pre_site_transient_update_themes', array($this, 'last_checked_now') );
    
    	/*
    	 * Disable Plugin Updates
    	 * 2.8 to 3.0
    	 */
    	add_action( 'pre_transient_update_plugins', array($this, 'last_checked_now') );
    	/*
    	 * 3.0
    	 */
    	add_filter( 'pre_site_transient_update_plugins', array($this, 'last_checked_now') );
    
    	/*
    	 * Disable Core Updates
    	 * 2.8 to 3.0
    	 */
    	add_filter( 'pre_transient_update_core', array($this, 'last_checked_now') );
    	/*
    	 * 3.0
    	 */
    	add_filter( 'pre_site_transient_update_core', array($this, 'last_checked_now') );
    }
    
    public function last_checked_now( $transient )
    {
    	include ABSPATH . WPINC . '/version.php';
    	$current = new stdClass;
    	$current->updates = array();
    	$current->version_checked = $wp_version;
    	$current->last_checked = time();
    
    	return $current;
    }

    I was also getting an error about a duplicate constructor in the OS_Disable_WordPress_Updates class. Remove

    function OS_Disable_WordPress_Updates() {
    	$this->__construct();
    }

    as it's redundant and causing issues for people on even remotely modern versions of PHP.

    http://wordpress.org/plugins/disable-wordpress-updates/

  2. Alphawolf
    Member
    Plugin Author

    Posted 8 months ago #

    Added in version 1.3.1!

    Thanks a lot, flynsarmy!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.