• I’ve been having this problem for quite some time to where I can update plugins etc all automatically but wordpress versions I cannot. When trying to update it says “Another update is currently in progress.”.

    I’ve tried looking for update locks, etc, and have essentially narrowed it down to the function create_lock() in class-wp-upgrader.php line 885

    For some reason when wordpress is trying to insert the core_updater.lock line in the wp_options table, it’s saying there’s a duplicate entry.

    // Try to lock.
    $q = $wpdb->prepare( "INSERT INTO <code>$wpdb->options</code> ( <code>option_name</code>, <code>option_value</code>, <code>autoload</code> ) VALUES (%s, %s, 'no') /* LOCK */", $lock_option, time() );
    $lock_result = $wpdb->query( $q );
    	
    echo "QUERY[   $q   ]<br>";
    echo "QUERY ERROR[   ".$wpdb->last_error."   ]<br>";

    This is what it returns
    QUERY[ INSERT INTOwp_options(option_name,option_value,autoload ) VALUES (‘core_updater.lock’, ‘1608054699’, ‘no’) /* LOCK */ ]
    QUERY ERROR[ Duplicate entry ‘core_updater.lock’ for key ‘option_name’ ]

    The funny thing? When I manually look at the table with Navicat, that line doesn’t exist, and I can manually run the query to insert it normally. Something is bugged here and I’m not quite sure what it is

    Disclaimer – I modified the code above in order to show me the error code and split up the syntaxes to ensure prepare() wasn’t messing up the query code

    • This topic was modified 5 years, 5 months ago by ryanericw.
    • This topic was modified 5 years, 5 months ago by ryanericw.
    • This topic was modified 5 years, 5 months ago by ryanericw.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ryanericw

    (@ryanericw)

    Running the query below returns 0 results:

    SELECT * FROM wp_options WHERE option_name="core_updater.lock"

    Thread Starter ryanericw

    (@ryanericw)

    Running the query below manually actually inserts the record:

    INSERT INTOwp_options(option_name,option_value,autoload) VALUES (‘core_updater.lock’, ‘1608054699’, ‘no’) /* LOCK */

    Then if I run the query
    SELECT * FROM wp_options WHERE option_name=”core_updater.lock”

    It will find the row. After I delete it manually, wordpress says it still exists which is insane.

    • This reply was modified 5 years, 5 months ago by ryanericw.
    Thread Starter ryanericw

    (@ryanericw)

    My modified static function that is displaying this code. Note – I’ve since manually upgraded again this time to 5.6. Once another WP update comes out, I’ll verify this is still an issue and then maybe I can narrow it down to a Database/Table issue.

    	public static function create_lock( $lock_name, $release_timeout = null ) {
    		global $wpdb;
    		if ( ! $release_timeout ) {
    			$release_timeout = HOUR_IN_SECONDS;
    		}
    		$lock_option = $lock_name . '.lock';
    
    		// Try to lock.
    		$q = $wpdb->prepare( "INSERT INTO <code>$wpdb->options</code> ( <code>option_name</code>, <code>option_value</code>, <code>autoload</code> ) VALUES (%s, %s, 'no') /* LOCK */", $lock_option, time() );
    		$lock_result = $wpdb->query( $q );
    	
    		echo "QUERY[   $q   ]<br>";
    		echo "QUERY ERROR[   ".$wpdb->last_error."   ]<br>";
    		//$test_result = $wpdb->query( "INSERT INTO wp_options (option_name, option_value, autoload) VALUES('ZZZ', '1', 'no')");
    		//if( ! $test_result ) echo "test failed";
    			
    		if ( ! $lock_result ) 
    		{
    			$lock_result = get_option( $lock_option );
    
    			// If a lock couldn't be created, and there isn't a lock, bail.
    			if ( ! $lock_result ) {
    				echo "There is where I'm failing<br>";
    				return false;
    			}
    
    			// Check to see if the lock is still valid. If it is, bail.
    			if ( $lock_result > ( time() - $release_timeout ) ) {
    				return false;
    			}
    
    			// There must exist an expired lock, clear it and re-gain it.
    			WP_Upgrader::release_lock( $lock_name );
    			return WP_Upgrader::create_lock( $lock_name, $release_timeout );
    		}
    
    		// Update the lock, as by this point we've definitely got a lock, just need to fire the actions.
    		update_option( $lock_option, time() );
    
    		return true;
    	}
    • This reply was modified 5 years, 5 months ago by ryanericw.
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘UPDATE to 5.6 Bug’ is closed to new replies.