1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-11 19:24:01 +02:00

[ticket/17077] Add proper locking in PHP without releasing form tokens

PHPBB3-17077
This commit is contained in:
Marc Alexander
2024-05-01 11:22:29 +02:00
parent 98929ca983
commit 6f45b46746
5 changed files with 26 additions and 30 deletions

View File

@@ -42,13 +42,15 @@ class phpbb_lock_posting_test extends phpbb_test_case
$this->assertFalse($this->lock->acquire(100, 'foo'));
$this->assertTrue($this->cache->_exists(sha1('100foo') . '_posting_lock'));
$this->lock->release();
$this->assertFalse($this->cache->_exists(sha1('100foo') . '_posting_lock'));
$this->assertFalse($this->lock->acquire(100, 'foo'));
$this->cache->put(sha1('100foo') . '_posting_lock', 'foo', -30);
$this->assertTrue($this->lock->acquire(100, 'foo'));
$this->assertTrue($this->cache->_exists(sha1('100foo') . '_posting_lock'));
$this->lock->release();
$this->lock->release(); // double release has no effect
$this->assertFalse($this->cache->_exists(sha1('100foo') . '_posting_lock'));
$this->config->offsetSet('ci_tests_no_lock_posting', true);
$this->assertTrue($this->lock->acquire(100, 'foo'));
$this->assertTrue($this->cache->_exists(sha1('100foo') . '_posting_lock'));
// Multiple acquires possible due to special ci test flag
$this->assertTrue($this->lock->acquire(100, 'foo'));
}
}
}