1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 14:14:04 +00:00

PHP 8.5 support

This commit adds support for building a docker image based on PHP 8.5
(RC). It also removes some unused code in tests that was triggering
deprecation warnings. For similar deprecation warnings coming from
testbench we have a temporary patch script until this is resolved
upstream.

This commit also adds logic to the DisallowSqliteAttach feature
leveraging the new native setAuthorizer() method, instead of loading
a compiled extension.

We also remove the unused `php` parameter from ci.yml
This commit is contained in:
Samuel Štancl 2025-10-19 18:44:58 +02:00
parent 91f6c61fcd
commit fadf1001f8
No known key found for this signature in database
GPG key ID: BA146259A1E16C57
7 changed files with 53 additions and 25 deletions

View file

@ -19,7 +19,7 @@ class DisallowSqliteAttach implements Feature
// Handle any already resolved connections
foreach (DB::getConnections() as $connection) {
if ($connection instanceof SQLiteConnection) {
if (! $this->loadExtension($connection->getPdo())) {
if (! $this->setAuthorizer($connection->getPdo())) {
return;
}
}
@ -28,16 +28,19 @@ class DisallowSqliteAttach implements Feature
// Apply the change to all sqlite connections resolved in the future
DB::extend('sqlite', function ($config, $name) {
$conn = app(ConnectionFactory::class)->make($config, $name);
$this->loadExtension($conn->getPdo());
$this->setAuthorizer($conn->getPdo());
return $conn;
});
}
protected function loadExtension(PDO $pdo): bool
protected function setAuthorizer(PDO $pdo): bool
{
// todo@php85 In PHP 8.5, we can use setAuthorizer() instead of loading an extension.
// However, this is currently blocked on https://github.com/phpredis/phpredis/issues/2688
if (PHP_VERSION_ID >= 80500) {
$this->setNativeAuthorizer($pdo);
return true;
}
static $loadExtensionSupported = method_exists($pdo, 'loadExtension');
if ((! $loadExtensionSupported) ||
@ -64,4 +67,13 @@ class DisallowSqliteAttach implements Feature
return true;
}
protected function setNativeAuthorizer(PDO $pdo): void
{
$pdo->setAuthorizer(static function (int $action): int {
return $action === 24 // SQLITE_ATTACH
? Pdo\Sqlite::DENY
: Pdo\Sqlite::OK;
});
}
}