From e191953942fe6b32917c5e01f27879db87e369ce Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 9 Dec 2015 14:13:05 +0100 Subject: [PATCH] Remove all locks after ttl from the db --- lib/private/lock/dblockingprovider.php | 6 +++--- tests/lib/lock/dblockingprovider.php | 8 +------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/private/lock/dblockingprovider.php b/lib/private/lock/dblockingprovider.php index 90657e6725..8d6ab52737 100644 --- a/lib/private/lock/dblockingprovider.php +++ b/lib/private/lock/dblockingprovider.php @@ -235,10 +235,10 @@ class DBLockingProvider extends AbstractLockingProvider { /** * cleanup empty locks */ - public function cleanEmptyLocks() { + public function cleanExpiredLocks() { $expire = $this->timeFactory->getTime(); $this->connection->executeUpdate( - 'DELETE FROM `*PREFIX*file_locks` WHERE `lock` = 0 AND `ttl` < ?', + 'DELETE FROM `*PREFIX*file_locks` WHERE `ttl` < ?', [$expire] ); } @@ -262,7 +262,7 @@ class DBLockingProvider extends AbstractLockingProvider { public function __destruct() { try { - $this->cleanEmptyLocks(); + $this->cleanExpiredLocks(); } catch (\Exception $e) { // If the table is missing, the clean up was successful if ($this->connection->tableExists('file_locks')) { diff --git a/tests/lib/lock/dblockingprovider.php b/tests/lib/lock/dblockingprovider.php index d679b1ea67..2032110f4f 100644 --- a/tests/lib/lock/dblockingprovider.php +++ b/tests/lib/lock/dblockingprovider.php @@ -85,13 +85,7 @@ class DBLockingProvider extends LockingProvider { $this->assertEquals(3, $this->getLockEntryCount()); - $this->instance->cleanEmptyLocks(); - - $this->assertEquals(3, $this->getLockEntryCount()); - - $this->instance->releaseAll(); - - $this->instance->cleanEmptyLocks(); + $this->instance->cleanExpiredLocks(); $this->assertEquals(2, $this->getLockEntryCount()); }