Skip to content

Commit

Permalink
ensuring null checks and better logging if scheduler is not instanti…
Browse files Browse the repository at this point in the history
…ated right
  • Loading branch information
irvins committed Dec 3, 2024
1 parent 93eef8c commit 6480330
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions ChartLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public function __construct()
if ($em) {
try {
$this->setScheduler(\ExternalModules\ExternalModules::getModuleInstance($em));
if ($this->scheduler === null) {
$this->emError("Scheduler module instance could not be initialized.");
}
} catch (\Exception $e) {
$this->setScheduler(null);
}
Expand Down Expand Up @@ -180,15 +183,26 @@ public function verifyUser($value, $recordId)

public function getSchedulerLink($recordId = '')
{
return $this->getScheduler()->getUrl('src/user', true,
$scheduler = $this->getScheduler();

if ($scheduler === null) {
$this->emError("Scheduler instance is null when trying to get URL.");
return null; // Or handle the error as needed
}

return $scheduler->getUrl('src/user', true,
true) . '&projectid=' . $this->getProjectId() . '&pid=' . $this->getProjectId() . '&NOAUTH&id=' . $recordId;
}

public function redirectToScheduler($recordId)
{
// redirect($this->getSchedulerLink($recordId));
$url = $this->getSchedulerLink($recordId);
header("Location: $url");
if ($url) {
header("Location: $url");
} else {
$this->emError("Cannot redirect to scheduler; URL is null.");
// Handle the error, possibly show a user-friendly message
}
$this->exitAfterHook();
}

Expand Down

0 comments on commit 6480330

Please sign in to comment.