1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 01:34:03 +00:00

fix path in feature class, minor refactor

This commit is contained in:
Samuel Štancl 2025-01-04 15:20:36 +01:00
parent 9c4d02de07
commit e2e20ad6db

View file

@ -43,24 +43,21 @@ class DisallowSqliteAttach implements Feature
static::$loadExtensionSupported = method_exists($pdo, 'loadExtension'); static::$loadExtensionSupported = method_exists($pdo, 'loadExtension');
} }
if (static::$loadExtensionSupported === false) { if (static::$loadExtensionSupported === false) return false;
return false; if (static::$extensionPath === false) return false;
}
$suffix = match (PHP_OS_FAMILY) { $suffix = match (PHP_OS_FAMILY) {
'Linux' => '.so', 'Linux' => 'so',
'Windows' => '.dll', 'Windows' => 'dll',
'Darwin' => '.dylib', 'Darwin' => 'dylib',
default => throw new Exception("The DisallowSqliteAttach feature doesn't support your operating system: " . PHP_OS_FAMILY), default => throw new Exception("The DisallowSqliteAttach feature doesn't support your operating system: " . PHP_OS_FAMILY),
}; };
$arch = php_uname('m'); $arch = php_uname('m');
$arm = $arch === 'aarch64' || $arch === 'arm64'; $arm = $arch === 'aarch64' || $arch === 'arm64';
static::$extensionPath ??= realpath(base_path('vendor/stancl/tenancy/src/extensions/lib/' . ($arm ? 'arm/' : '') . 'noattach' . $suffix)); static::$extensionPath ??= realpath(base_path('vendor/stancl/tenancy/extensions/lib/' . ($arm ? 'arm/' : '') . 'noattach.' . $suffix));
if (static::$extensionPath === false) { if (static::$extensionPath === false) return false;
return false;
}
$pdo->loadExtension(static::$extensionPath); // @phpstan-ignore method.notFound $pdo->loadExtension(static::$extensionPath); // @phpstan-ignore method.notFound