solve the localhost/docker issue by falling back to 'http://localhost/' in docker environments which will always work for the cron run method

This commit is contained in:
HB9HIL
2025-08-03 21:46:22 +02:00
parent 96663cbdf9
commit a95f03b214

View File

@@ -92,7 +92,17 @@ class cron extends CI_Controller {
echo "CRON: " . $cron->id . " -> is due: " . $isdue_result . "\n";
echo "CRON: " . $cron->id . " -> RUNNING...\n";
$url = local_url() . $cron->function;
if (ENVIRONMENT == "docker") {
// In Docker, we use the localhost[:80] to call the cron directly inside the container
$url = 'http://localhost/' . $cron->function;
log_message('debug', 'Docker Environment detected. Using URL: ' . $url);
} else {
// In other environments, we use the local_url() function to get the default url
// Even this local_url() helper created in https://github.com/wavelog/wavelog/pull/795 is not really necessary anymore
// we keep it in case of users do fancy things with it. It doesn't hurt to have it here as it usually returns the base_url
// from the config.php file.
$url = local_url() . $cron->function;
}
if (ENVIRONMENT == "development") {
echo "CRON: " . $cron->id . " -> URL: " . $url . "\n";
}