Skip to content

Commit

Permalink
pkp#52 PHP 7.4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir committed Sep 12, 2024
1 parent 62d3ccd commit e17e299
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
27 changes: 18 additions & 9 deletions IThenticate.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,28 @@ public function getEnabledFeature($feature = null) {
static $result;

if (!isset($result) && !$this->validateAccess($result)) {
return $this->suppressApiRequestException
? []
: throw new \Exception('unable to validate access details');
if ($this->suppressApiRequestException) {
return [];
}

throw new \Exception('unable to validate access details');
}

if (!$feature) {
return json_decode($result, true);
}

$self = $this;
return data_get(
json_decode($result, true),
$feature,
fn () => $this->suppressApiRequestException
? null
: throw new \Exception("Feature details {$feature} does not exist")
function () use ($self, $feature) {
if ($self->suppressApiRequestException) {
return null;
}

throw new \Exception("Feature details {$feature} does not exist");
}
);
}

Expand Down Expand Up @@ -684,9 +691,11 @@ public function makeApiRequest($method, $url, $options = []) {
)
);

$this->suppressApiRequestException
? error_log($exception->__toString())
: throw $exception;
if ($this->suppressApiRequestException) {
error_log($exception->__toString());
} else {
throw $exception;
}
}

return $response;
Expand Down
11 changes: 8 additions & 3 deletions TestIThenticate.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,17 @@ public function getEnabledFeature($feature = null) {
return json_decode($result, true);
}

$self = $this;
$featureStatus = data_get(
json_decode($result, true),
$feature,
fn () => $this->suppressApiRequestException
? null
: throw new \Exception("Feature details {$feature} does not exist")
function () use ($self, $feature) {
if ($self->suppressApiRequestException) {
return null;
}

throw new \Exception("Feature details {$feature} does not exist");
}
);

error_log("iThenticate specific enable feature details {$featureStatus}");
Expand Down

0 comments on commit e17e299

Please sign in to comment.