Skip to content

Commit

Permalink
Fix issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tertek authored Jan 26, 2023
1 parent 3f9ec64 commit 7900e09
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions deviceTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,20 @@ public function __construct()
// Check if we are in testing context
$this->isTesting = ExternalModules::isTesting();

// Setup Project Context if pid is available through request and constant is not yet defined
if(isset($_GET["pid"]) && !defined('PROJECT_ID')) {
define('PROJECT_ID', $this->escape($_GET["pid"]));
// global $Proj;
// $Proj = new Project(PROJECT_ID);
}
# Put this into try/catch so that in case of exception module can still be enabled/disabled
try {
// Setup Project Context if pid is available through request and constant is not yet defined
if(isset($_GET["pid"]) && !defined('PROJECT_ID')) {
define('PROJECT_ID', $this->escape($_GET["pid"]));
}

// Set Device Project variables
$this->setDeviceProject();

// Set Device Project variables
$this->setDeviceProject();
} catch (\Exception $e) {
error_log("Error during module class construction. This exception has been caught to prevent module enable/disable problems.");
error_log($e);
}

}

Expand All @@ -89,7 +94,9 @@ public function __construct()
*/
private function setDeviceProject() {
$this->devices_project_id = $this->isTesting ? self::getTestSystemSetting("devices-project") : $this->getSystemSetting("devices-project");
$this->devices_event_id = (new \Project( $this->devices_project_id ))->firstEventId;
if(!empty($this->devices_project_id)) {
$this->devices_event_id = (new \Project( $this->devices_project_id ))->firstEventId;
}
}

/**
Expand Down Expand Up @@ -1011,4 +1018,4 @@ public static function escape($value){
}
}

}
}

0 comments on commit 7900e09

Please sign in to comment.