Commit 2f60d007 authored by Daniel Hürtgen's avatar Daniel Hürtgen

[FEATURE] Allow to configure lock implementation expiration

parent bdf597f4
......@@ -43,6 +43,11 @@ class Configuration implements SingletonInterface
*/
protected $lockImplementationBuilder = [];
/**
* @var int
*/
protected $lockImplementationExpiration = 0;
/**
* @var array
*/
......@@ -235,6 +240,29 @@ class Configuration implements SingletonInterface
return $this;
}
/**
* @return int
*/
public function getLockImplementationExpiration()
{
return $this->lockImplementationExpiration;
}
/**
* @param int $expiration
*
* @return $this
*/
public function setLockImplementationExpiration($expiration)
{
$expiration = (int)$expiration;
if ($expiration >= 0) {
$this->lockImplementationExpiration = $expiration;
}
return $this;
}
/**
* @param null|string $lockImplementation
*
......
......@@ -237,6 +237,36 @@ class ConfigurationTest extends UnitTestCase
$this->assertSame($lockImplementationBuilder, $sut->getLockImplementationBuilder());
}
/**
* @test
*/
public function itIsPossibleToSetLockImplementationExpirationViaGlobalsConfigurationArray()
{
$expiration = (new \DateTime())->getTimestamp();
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locking'] = [
'lockImplementationExpiration' => $expiration,
];
$sut = new Configuration();
$this->assertSame($expiration, $sut->getLockImplementationExpiration());
}
/**
* @test
*/
public function itIsPossibleToSetLockImplementationExpirationViaConfigurationArray()
{
$expiration = (new \DateTime())->getTimestamp();
$configuration = [
'lockImplementationExpiration' => $expiration,
];
$sut = new Configuration($configuration);
$this->assertSame($expiration, $sut->getLockImplementationExpiration());
}
/**
* @test
*/
......@@ -417,6 +447,27 @@ class ConfigurationTest extends UnitTestCase
$this->assertNull($sut->getLockImplementationBuilder(\stdClass::class));
}
/**
* @test
*/
public function itReturnsPerDefaultZeroAsLockImplementationExpiration()
{
$sut = new Configuration();
$this->assertSame(0, $sut->getLockImplementationExpiration());
}
/**
* @test
*/
public function itAllowsOnlyPositiveValuesOrZeroAsLockImplementationExpiration()
{
$expiration = -1;
$sut = new Configuration(['lockImplementationExpiration' => $expiration]);
$this->assertSame(0, $sut->getLockImplementationExpiration());
}
/**
* @test
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment