From cb8260f03314e627a8fe2de0c28355cebce5fd8f Mon Sep 17 00:00:00 2001 From: prasad <prasad@vtiger.com> Date: Sun, 11 Feb 2018 17:29:23 +0530 Subject: [PATCH] Fixes #502: Extend support to detect cron trigger from CLI (cgi-fcgi etc... generic) --- vtigercron.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vtigercron.php b/vtigercron.php index 0a9746022..886ae0bd1 100644 --- a/vtigercron.php +++ b/vtigercron.php @@ -37,7 +37,11 @@ if($php < 50300){ $mailbody ="Instance dir : $root_directory <br/> Site Url : $site_URL <br/> Host Name : $hostName<br/>"; $mailSubject = "[Alert] "; -if(PHP_SAPI === "cli" || (isset($_SESSION["authenticated_user_id"]) && isset($_SESSION["app_unique_key"]) && $_SESSION["app_unique_key"] == $application_unique_key)){ +function vtigercron_detect_run_in_cli(){ + return (!isset($_SERVER['SERVER_SOFTWARE']) && (php_sapi_name() == 'cli' || is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0)); +} + +if(vtigercron_detect_run_in_cli() || (isset($_SESSION["authenticated_user_id"]) && isset($_SESSION["app_unique_key"]) && $_SESSION["app_unique_key"] == $application_unique_key)){ $cronTasks = false; if (isset($_REQUEST['service'])) { -- GitLab