diff --git a/lib/poller-common.php b/lib/poller-common.php index 3d6dd47..6755cba 100644 --- a/lib/poller-common.php +++ b/lib/poller-common.php @@ -198,8 +198,10 @@ function weathermap_cron_part($value, $checkstring) { continue; } - $low = (int) $matches[2]; - $high = isset($matches[3]) && $matches[3] !== '' ? (int) $matches[3] : ($step > 1 ? PHP_INT_MAX : $low); + // N/step runs from N to the end of the field, even when the step is 1. + $has_step = isset($matches[4]) && $matches[4] !== ''; + $low = (int) $matches[2]; + $high = isset($matches[3]) && $matches[3] !== '' ? (int) $matches[3] : ($has_step ? PHP_INT_MAX : $low); if ($value >= $low && $value <= $high && ($value - $low) % $step == 0) { return true; diff --git a/tests/Unit/PollerCrashGuardTest.php b/tests/Unit/PollerCrashGuardTest.php index 9633019..b500c52 100644 --- a/tests/Unit/PollerCrashGuardTest.php +++ b/tests/Unit/PollerCrashGuardTest.php @@ -111,8 +111,8 @@ function wmCrashGuardRender(string $link_lines): int { describe('weathermap_cron_part()', function (): void { it('matches the forms crontab allows', function (): void { - $matches = ['*' => [7], '5' => [5], '*/15' => [30], '0,15,30' => [15], '10-20' => [12], '10-20/5' => [15], '5/10' => [25]]; - $misses = ['5' => [6], '*/15' => [31], '0,15,30' => [20], '10-20' => [21], '10-20/5' => [16], '5/10' => [0], '*/0' => [0], 'x*/5' => [10]]; + $matches = ['*' => [7], '5' => [5], '*/15' => [30], '0,15,30' => [15], '10-20' => [12], '10-20/5' => [15], '5/10' => [25], '5/1' => [5, 6, 59]]; + $misses = ['5' => [6], '5/1' => [4], '*/15' => [31], '0,15,30' => [20], '10-20' => [21], '10-20/5' => [16], '5/10' => [0], '*/0' => [0], 'x*/5' => [10]]; foreach ($matches as $field => $values) { foreach ($values as $value) {