protected function getTestLock(bool
$create_lock = FALSE
): int
{ // There is a risk that the generated random number is a duplicate. This
// would cause different tests to try to use the same database prefix.
// Therefore, if running with a concurrency of greater than 1, we need to
// create a lock.
if (getenv('RUN_TESTS_CONCURRENCY'
) > 1
) { $create_lock = TRUE;
} do { $lock_id =
mt_rand(10000000, 99999999
);
if ($create_lock && @
symlink(__FILE__,
$this->
getLockFile($lock_id)) === FALSE
) { // If we can't create a symlink, the lock ID is in use. Generate another
// one. Symlinks are used because they are atomic and reliable.
$lock_id = NULL;
} } while ($lock_id === NULL
);
return $lock_id;
} /**
* Releases a lock.
*
* @return bool
* TRUE if successful, FALSE if not.
*/