: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
namespace WPML\Utilities;
class KeyedLock extends Lock {
/** @var string $keyName */
public function __construct( \wpdb $wpdb, $name ) {
$this->keyName = 'wpml.' . $name . '.lock.key';
parent::__construct( $wpdb, $name );
* @param int $release_timeout
* @return string|false The key or false if could not acquire the lock
public function create( $key = null, $release_timeout = null ) {
$acquired = parent::create( $release_timeout );
$key = wp_generate_uuid4();
update_option( $this->keyName, $key );
} elseif ( $key === get_option( $this->keyName ) ) {
public function release() {
delete_option( $this->keyName );
return parent::release();
private function extendTimeout() {
update_option( $this->name, time() );