function _wp_upgrade_revisions_of_post( $post,
$revisions ) { global $wpdb;
// Add post option exclusively.
$lock = "revision-upgrade-{
$post->ID
}";
$now =
time();
$result =
$wpdb->
query( $wpdb->
prepare( "INSERT IGNORE INTO `
$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, 'no') /* LOCK */",
$lock,
$now ) );
if ( !
$result ) { // If we couldn't get a lock, see how old the previous lock is.
$locked =
get_option( $lock );
if ( !
$locked ) { /*
* Can't write to the lock, and can't read the lock.
* Something broken has happened.
*/
return false;
} if ( $locked >
$now - HOUR_IN_SECONDS
) { // Lock is not too old: some other process may be upgrading this post. Bail.