diff --git a/src/ChurchCRM/Service/SystemService.php b/src/ChurchCRM/Service/SystemService.php index af4d16becf..d2ed327757 100644 --- a/src/ChurchCRM/Service/SystemService.php +++ b/src/ChurchCRM/Service/SystemService.php @@ -380,7 +380,7 @@ function runTimerJobs() $diff = $previous->diff($now); // calculate the difference. if (!SystemConfig::getValue("sLastIntegrityCheckTimeStamp") || $diff->h >= SystemConfig::getValue("sIntegrityCheckInterval")) // if there was no previous backup, or if the interval suggests we do a backup now. { - $integrityCheckFile = dirname(__DIR__) . "/integrityCheck.json"; + $integrityCheckFile = SystemURLs::getDocumentRoot() . "/integrityCheck.json"; $appIntegrity = $this->verifyApplicationIntegrity(); file_put_contents($integrityCheckFile, json_encode($appIntegrity)); $now = new \DateTime(); // update the LastBackupTimeStamp. diff --git a/src/ChurchCRM/Service/TaskService.php b/src/ChurchCRM/Service/TaskService.php index f81fa1e601..1828934638 100644 --- a/src/ChurchCRM/Service/TaskService.php +++ b/src/ChurchCRM/Service/TaskService.php @@ -18,7 +18,10 @@ public function __construct() function getAdminTasks() { requireUserGroupMembership("bAdmin"); - $integrityCheckData = json_decode(file_get_contents(SystemURLs::getDocumentRoot()."/integrityCheck.json")); + if (file_exists(SystemURLs::getDocumentRoot()."/integrityCheck.json")) + { + $integrityCheckData = json_decode(file_get_contents(SystemURLs::getDocumentRoot()."/integrityCheck.json")); + } $tasks = array(); if (SystemConfig::getValue("bRegistered") != 1) { @@ -45,7 +48,7 @@ function getAdminTasks() { array_push($tasks, $this->addTask(gettext("New Release") . " " . $this->latestVersion["name"], SystemURLs::getRootPath()."/UpgradeCRM.php", true)); } - if($integrityCheckData->status == "failure") { + if($integrityCheckData == null || $integrityCheckData->status == "failure") { array_push($tasks, $this->addTask(gettext("Application Integrity Check Failed"), SystemURLs::getRootPath()."/IntegrityCheck.php", true)); } diff --git a/src/IntegrityCheck.php b/src/IntegrityCheck.php index 8e9554d2e0..7ab9b086a1 100644 --- a/src/IntegrityCheck.php +++ b/src/IntegrityCheck.php @@ -4,6 +4,8 @@ require 'Include/Config.php'; require 'Include/Functions.php'; +use ChurchCRM\dto\SystemURLs; + //Set the page title $sPageTitle = gettext('Integrity Check Results'); if (!$_SESSION['bAdmin']) @@ -12,8 +14,16 @@ exit; } require 'Include/Header.php'; -$integrityCheckFile = __DIR__ ."/integrityCheck.json"; -$IntegrityCheckDetails = json_decode(file_get_contents($integrityCheckFile)); +$integrityCheckFile = SystemURLs::getDocumentRoot() ."/integrityCheck.json"; + +if (file_exists($integrityCheckFile)) +{ + $IntegrityCheckDetails = json_decode(file_get_contents($integrityCheckFile)); +} +else { + $IntegrityCheckDetails->status = "failure"; + $IntegrityCheckDetails->message = "integrityCheck.json file missing"; +} if ($IntegrityCheckDetails->status == "failure") {