Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't throw if open_basedir is enabled #1451

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/SDK/Resource/Detectors/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@

foreach ($paths as $path) {
$file = $this->dir . $path;
if (is_file($file) && is_readable($file)) {
$contents = file_get_contents($file);

return $contents !== false ? trim($contents) : null;
try {
if (is_file($file) && is_readable($file)) {
$contents = file_get_contents($file);

return $contents !== false ? trim($contents) : null;
}
} catch (ErrorException $ex) {

Check failure on line 62 in src/SDK/Resource/Detectors/Host.php

View workflow job for this annotation

GitHub Actions / php (8.5, true, --ignore-platform-reqs)

UndefinedClass

src/SDK/Resource/Detectors/Host.php:62:22: UndefinedClass: Class, interface or enum named OpenTelemetry\SDK\Resource\Detectors\ErrorException does not exist (see https://psalm.dev/019)

Check failure on line 62 in src/SDK/Resource/Detectors/Host.php

View workflow job for this annotation

GitHub Actions / php (8.5, true, --ignore-platform-reqs)

Caught class OpenTelemetry\SDK\Resource\Detectors\ErrorException not found.

Check warning on line 62 in src/SDK/Resource/Detectors/Host.php

View workflow job for this annotation

GitHub Actions / php (8.5, true, --ignore-platform-reqs)

OpenTelemetry\SDK\Resource\Detectors\Host has uncovered dependency on OpenTelemetry\SDK\Resource\Detectors\ErrorException (SDK)
// This may occur if open_basedir is enabled.
}
}

Expand All @@ -66,10 +70,14 @@
private function getBsdId(): ?string
{
$file = $this->dir . self::PATH_ETC_HOSTID;
if (is_file($file) && is_readable($file)) {
$contents = file_get_contents($file);
try {
if (is_file($file) && is_readable($file)) {
$contents = file_get_contents($file);

return $contents !== false ? trim($contents) : null;
return $contents !== false ? trim($contents) : null;
}
} catch (ErrorException $ex) {

Check failure on line 79 in src/SDK/Resource/Detectors/Host.php

View workflow job for this annotation

GitHub Actions / php (8.5, true, --ignore-platform-reqs)

UndefinedClass

src/SDK/Resource/Detectors/Host.php:79:18: UndefinedClass: Class, interface or enum named OpenTelemetry\SDK\Resource\Detectors\ErrorException does not exist (see https://psalm.dev/019)

Check failure on line 79 in src/SDK/Resource/Detectors/Host.php

View workflow job for this annotation

GitHub Actions / php (8.5, true, --ignore-platform-reqs)

Caught class OpenTelemetry\SDK\Resource\Detectors\ErrorException not found.

Check warning on line 79 in src/SDK/Resource/Detectors/Host.php

View workflow job for this annotation

GitHub Actions / php (8.5, true, --ignore-platform-reqs)

OpenTelemetry\SDK\Resource\Detectors\Host has uncovered dependency on OpenTelemetry\SDK\Resource\Detectors\ErrorException (SDK)
// This may occur if open_basedir is enabled.
}

$out = exec('which kenv && kenv -q smbios.system.uuid');
Expand Down
Loading