- Issue created by @erwangel
If more than one ip are entered in the allowed ips field in settings, one may add a space after comma by habit or for better readability. E.g.: "123.456.789.123, 456.789.101, 127.0.0.1"
instead of "123.456.789.123,456.789.101,127.0.0.1"
. Of course this can happen even with just one ip, e.g. "127.0.0.1 "
instead of "127.0.0.1"
.
When the calling ip is tasted against the allowed ips inside function elysia_cron_run, values of the array obtained by exploding the allowed ips string must be trimmed in order to eliminate possible unwanted white spaces.
Enter an ip with spaces in the allowed ips field as of the examples above, then try to run the cron. Cron fails to run because the allowed ip is not recognized.
Around line 1270 of elysia_cron.module:
// if ($allowed_hosts && !in_array(ip_address(), explode(',', $allowed_hosts))) {
if ($allowed_hosts && !in_array(ip_address(), array_map('trim', explode(',', $allowed_hosts)))) {
At the same time we can improve the debug message:
// elysia_cron_debug('Cron ip address mismatch, skipping run');
elysia_cron_debug('Cron ip address mismatch, skipping run. Calling ip: %ip.', ['%ip' => ip_address()]);
Displaying the calling ip was especially useful to debug when an server send a short ipv6 address while in allowed ip field I had the full ipv6 ip.
Active
2.9
Code