mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-14 06:04:03 +00:00
SQLite improvements
- (BC BREAK) Remove $WAL static property. We instead just let Laravel use its journal_mode config now - Remove journal, wal, and shm files when deleting tenant DB - Check that the system is 64-bit when using NoAttach (we don't build 32 bit extensions) - Use local static instead of a class static property for caching loadExtensionSupported
This commit is contained in:
parent
4e22c4dd6e
commit
13a2209f11
3 changed files with 38 additions and 63 deletions
|
|
@ -13,7 +13,6 @@ use Stancl\Tenancy\Contracts\Feature;
|
|||
|
||||
class DisallowSqliteAttach implements Feature
|
||||
{
|
||||
protected static bool|null $loadExtensionSupported = null;
|
||||
public static string|false|null $extensionPath = null;
|
||||
|
||||
public function bootstrap(): void
|
||||
|
|
@ -38,20 +37,12 @@ class DisallowSqliteAttach implements Feature
|
|||
|
||||
protected function loadExtension(PDO $pdo): bool
|
||||
{
|
||||
if (static::$loadExtensionSupported === null) {
|
||||
// todo@sqlite refactor to local static
|
||||
static::$loadExtensionSupported = method_exists($pdo, 'loadExtension');
|
||||
}
|
||||
static $loadExtensionSupported = method_exists($pdo, 'loadExtension');
|
||||
|
||||
if (static::$loadExtensionSupported === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (static::$extensionPath === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// todo@sqlite we may want to check for 64 bit
|
||||
if ((! $loadExtensionSupported) ||
|
||||
(static::$extensionPath === false) ||
|
||||
(PHP_INT_SIZE !== 8)
|
||||
) return false;
|
||||
|
||||
$suffix = match (PHP_OS_FAMILY) {
|
||||
'Linux' => 'so',
|
||||
|
|
@ -64,9 +55,7 @@ class DisallowSqliteAttach implements Feature
|
|||
$arm = $arch === 'aarch64' || $arch === 'arm64';
|
||||
|
||||
static::$extensionPath ??= realpath(base_path('vendor/stancl/tenancy/extensions/lib/' . ($arm ? 'arm/' : '') . 'noattach.' . $suffix));
|
||||
if (static::$extensionPath === false) {
|
||||
return false;
|
||||
}
|
||||
if (static::$extensionPath === false) return false;
|
||||
|
||||
$pdo->loadExtension(static::$extensionPath); // @phpstan-ignore method.notFound
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue