Skip to content
Snippets Groups Projects
Commit 5286bb03 authored by Marko Ivancic's avatar Marko Ivancic
Browse files

Adapt to non-nullable config options

parent 843f036d
No related branches found
No related tags found
1 merge request!2GUI tweaks
Pipeline #76308 passed
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
......@@ -157,13 +157,13 @@ $config = [
*
* Maximum execution time for the job runner. You can use this option to limit job runner activity by combining
* when the job runner will run (using cron configuration) and how long the job runner will be active
* (execution time). This can be null, meaning it will run indefinitely, or can be set as a duration
* (execution time). This can be false, meaning it will run indefinitely, or can be set as a duration
* for DateInterval, examples being below. Note that when the job runner is run using Cron user
* interface in SimpleSAMLphp, the duration will be taken from the 'max_execution_time' ini
* setting, and will override this setting if ini setting is shorter.
* @see https://www.php.net/manual/en/dateinterval.construct.php
*/
ModuleConfiguration::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME => null,
ModuleConfiguration::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME => false,
//ModuleConfiguration::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME => 'PT9M', // 9 minutes
//ModuleConfiguration::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME => 'PT59M', // 59 minutes
//ModuleConfiguration::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME => 'P1D', // 1 day
......@@ -172,7 +172,7 @@ $config = [
* Number of processed jobs after which the job runner should take a 1-second pause.
*
* This option was introduced so that the job runner can act in a more resource friendly fashion when facing
* backend store. If the value is null, there will be no pause.
* backend store. If the value is false, there will be no pause.
*/
ModuleConfiguration::OPTION_JOB_RUNNER_SHOULD_PAUSE_AFTER_NUMBER_OF_JOBS_PROCESSED => 10,
......
......@@ -87,7 +87,7 @@ class ModuleConfiguration
{
$value = $this->get(self::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME);
if (is_null($value)) {
if ($value === false) {
return null;
}
......@@ -109,13 +109,13 @@ class ModuleConfiguration
{
$value = $this->get(self::OPTION_JOB_RUNNER_SHOULD_PAUSE_AFTER_NUMBER_OF_JOBS_PROCESSED);
if (is_null($value)) {
if ($value === false) {
return null;
}
if (! is_int($value)) {
$message = sprintf(
'Option \'%s\' must be defined either as null, or positive integer.',
'Option \'%s\' must be defined either as false, or positive integer.',
self::OPTION_JOB_RUNNER_SHOULD_PAUSE_AFTER_NUMBER_OF_JOBS_PROCESSED
);
throw new InvalidConfigurationException($message);
......
......@@ -48,7 +48,7 @@ $config = [
],
],
ModuleConfiguration::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME => null,
ModuleConfiguration::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME => false,
ModuleConfiguration::OPTION_JOB_RUNNER_SHOULD_PAUSE_AFTER_NUMBER_OF_JOBS_PROCESSED => 10,
......
......@@ -219,7 +219,7 @@ class ModuleConfigurationTest extends TestCase
{
$moduleConfiguration = new ModuleConfiguration(
null,
[ModuleConfiguration::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME => false]
[ModuleConfiguration::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME => []]
);
$this->expectException(InvalidConfigurationException::class);
......@@ -255,7 +255,7 @@ class ModuleConfigurationTest extends TestCase
{
$moduleConfiguration = new ModuleConfiguration(
null,
[ModuleConfiguration::OPTION_JOB_RUNNER_SHOULD_PAUSE_AFTER_NUMBER_OF_JOBS_PROCESSED => null]
[ModuleConfiguration::OPTION_JOB_RUNNER_SHOULD_PAUSE_AFTER_NUMBER_OF_JOBS_PROCESSED => false]
);
$this->assertNull($moduleConfiguration->getJobRunnerShouldPauseAfterNumberOfJobsProcessed());
......@@ -268,7 +268,7 @@ class ModuleConfigurationTest extends TestCase
{
$moduleConfiguration = new ModuleConfiguration(
null,
[ModuleConfiguration::OPTION_JOB_RUNNER_SHOULD_PAUSE_AFTER_NUMBER_OF_JOBS_PROCESSED => false]
[ModuleConfiguration::OPTION_JOB_RUNNER_SHOULD_PAUSE_AFTER_NUMBER_OF_JOBS_PROCESSED => []]
);
$this->expectException(InvalidConfigurationException::class);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment