Merge pull request #13571 from inietov/fixes/require_acceptance_on_null

Fixed Attempt to read property require_acceptance on null [rollbar-3557]
This commit is contained in:
snipe 2023-09-07 18:11:42 +01:00 committed by GitHub
commit 67cad9c751
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 10 deletions

View file

@ -323,8 +323,11 @@ class License extends Depreciable
*/ */
public function checkin_email() public function checkin_email()
{ {
if ($this->category) {
return $this->category->checkin_email; return $this->category->checkin_email;
} }
return false;
}
/** /**
* Determine whether the user should be required to accept the license * Determine whether the user should be required to accept the license
@ -335,9 +338,13 @@ class License extends Depreciable
*/ */
public function requireAcceptance() public function requireAcceptance()
{ {
if ($this->category) {
return $this->category->require_acceptance; return $this->category->require_acceptance;
} }
return false;
}
/** /**
* Checks for a category-specific EULA, and if that doesn't exist, * Checks for a category-specific EULA, and if that doesn't exist,
* checks for a settings level EULA * checks for a settings level EULA
@ -348,16 +355,18 @@ class License extends Depreciable
*/ */
public function getEula() public function getEula()
{ {
if ($this->category){
if ($this->category->eula_text) { if ($this->category->eula_text) {
return Helper::parseEscapedMarkedown($this->category->eula_text); return Helper::parseEscapedMarkedown($this->category->eula_text);
} elseif ($this->category->use_default_eula == '1') { } elseif ($this->category->use_default_eula == '1') {
return Helper::parseEscapedMarkedown(Setting::getSettings()->default_eula_text); return Helper::parseEscapedMarkedown(Setting::getSettings()->default_eula_text);
} else {
return false;
} }
} }
return false;
}
/** /**
* Establishes the license -> assigned user relationship * Establishes the license -> assigned user relationship
* *

View file

@ -48,8 +48,11 @@ class LicenseSeat extends SnipeModel implements ICompanyableChild
*/ */
public function requireAcceptance() public function requireAcceptance()
{ {
if ($this->license && $this->license->category) {
return $this->license->category->require_acceptance; return $this->license->category->require_acceptance;
} }
return false;
}
public function getEula() public function getEula()
{ {