From bf99b5bd04e112fbd164032a7d7069bc37cf34c0 Mon Sep 17 00:00:00 2001 From: Gwilyn Date: Mon, 1 Sep 2025 17:24:07 +1000 Subject: [PATCH 1/5] Add interfaces dependency. --- composer.json | 1 + composer.lock | 57 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 82bac99..e605ed4 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ "ext-dom": "*", "ext-libxml": "*", "ext-pdo": "*", + "karmabunny/interfaces": "^1.0", "karmabunny/kb": "^3.58" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 65d9fbc..d904e45 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,59 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "22d44dd64f233611aadecc3c8862800f", + "content-hash": "5d95984d1823ae80fdd687287b084b2e", "packages": [ + { + "name": "karmabunny/interfaces", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/Karmabunny/kbinterfaces.git", + "reference": "ec4b6a46b55b4449996c006ba5cb500f31848d2e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Karmabunny/kbinterfaces/zipball/ec4b6a46b55b4449996c006ba5cb500f31848d2e", + "reference": "ec4b6a46b55b4449996c006ba5cb500f31848d2e", + "shasum": "" + }, + "require": { + "php": "^7.2|^8" + }, + "require-dev": { + "phpcompatibility/php-compatibility": "^9.3", + "phpstan/phpstan": "^2.1", + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "karmabunny\\interfaces\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Karmabunny", + "email": "info@karmabunny.com.au" + } + ], + "description": "Base KB interfaces", + "keywords": [ + "interfaces", + "karmabunny", + "kb", + "utilities" + ], + "support": { + "issues": "https://github.com/Karmabunny/kbinterfaces/issues", + "source": "https://github.com/Karmabunny/kbinterfaces/tree/v1.0.0" + }, + "time": "2025-09-01T05:46:40+00:00" + }, { "name": "karmabunny/kb", "version": "v3.58.35", @@ -2186,12 +2237,12 @@ "version": "3.6.0", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625", "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625", "shasum": "" }, From df2988557e6dff37ef081c8df5cf90603a4d71ec Mon Sep 17 00:00:00 2001 From: Gwilyn Date: Mon, 1 Sep 2025 17:25:42 +1000 Subject: [PATCH 2/5] Add driver interface. --- src/Drivers/PdbMysql.php | 19 ++++--- src/Drivers/PdbNoDriver.php | 18 +++---- src/Drivers/PdbPgsql.php | 18 +++---- src/Drivers/PdbSqlite.php | 18 +++---- src/Pdb.php | 89 +------------------------------ src/PdbDriverInterface.php | 102 ++++++++++++++++++++++++++++++++++++ 6 files changed, 140 insertions(+), 124 deletions(-) create mode 100644 src/PdbDriverInterface.php diff --git a/src/Drivers/PdbMysql.php b/src/Drivers/PdbMysql.php index 54bfede..f7bc201 100644 --- a/src/Drivers/PdbMysql.php +++ b/src/Drivers/PdbMysql.php @@ -2,7 +2,6 @@ namespace karmabunny\pdb\Drivers; -use InvalidArgumentException; use karmabunny\kb\Time; use karmabunny\pdb\Exceptions\ConnectionException; use karmabunny\pdb\Models\PdbColumn; @@ -70,7 +69,7 @@ public function isMariadb(): bool /** @inheritdoc */ - public function getPermissions() + public function getPermissions(): array { $q = "SHOW GRANTS FOR CURRENT_USER()"; $res = $this->query($q, [], 'col'); @@ -100,7 +99,7 @@ public function getPermissions() /** @inheritdoc */ - public function getTableNames(string $filter = '*', bool $strip = true) + public function getTableNames(string $filter = '*', bool $strip = true): array { $q = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES @@ -139,7 +138,7 @@ public function getTableNames(string $filter = '*', bool $strip = true) /** @inheritdoc */ - public function tableExists(string $table) + public function tableExists(string $table): bool { $q = "SELECT 1 FROM INFORMATION_SCHEMA.TABLES @@ -158,7 +157,7 @@ public function tableExists(string $table) /** @inheritdoc */ - public function fieldList(string $table) + public function fieldList(string $table): array { $q = "SELECT COLUMN_NAME, @@ -228,7 +227,7 @@ public function fieldList(string $table) /** @inheritdoc */ - public function indexList(string $table) + public function indexList(string $table): array { $q = "SELECT INDEX_NAME, @@ -265,7 +264,7 @@ public function indexList(string $table) /** @inheritdoc */ - public function getForeignKeys(string $table) + public function getForeignKeys(string $table): array { $q = "SELECT K.CONSTRAINT_NAME, @@ -314,7 +313,7 @@ public function getForeignKeys(string $table) /** @inheritdoc */ - public function getDependentKeys(string $table) + public function getDependentKeys(string $table): array { $q = "SELECT K.CONSTRAINT_NAME, @@ -365,7 +364,7 @@ public function getDependentKeys(string $table) /** @inheritdoc */ - public function getTableAttributes(string $table) + public function getTableAttributes(string $table): array { $q = "SELECT T.CREATE_TIME, @@ -393,7 +392,7 @@ public function getTableAttributes(string $table) /** @inheritdoc */ - public function extractEnumArr(string $table, string $column) + public function extractEnumArr(string $table, string $column): array { Pdb::validateIdentifier($table); Pdb::validateIdentifier($column); diff --git a/src/Drivers/PdbNoDriver.php b/src/Drivers/PdbNoDriver.php index 2a0aa04..cd60f2d 100644 --- a/src/Drivers/PdbNoDriver.php +++ b/src/Drivers/PdbNoDriver.php @@ -8,56 +8,56 @@ class PdbNoDriver extends Pdb { - public function getPermissions() + public function getPermissions(): array { throw new Exception('Not implemented: ' . __METHOD__); } - public function getForeignKeys(string $table) + public function getForeignKeys(string $table): array { throw new Exception('Not implemented: ' . __METHOD__); } - public function getDependentKeys(string $table) + public function getDependentKeys(string $table): array { throw new Exception('Not implemented: ' . __METHOD__); } /** @inheritdoc */ - public function getTableAttributes(string $table) + public function getTableAttributes(string $table): array { throw new Exception('Not implemented: ' . __METHOD__); } - public function extractEnumArr(string $table, string $column) + public function extractEnumArr(string $table, string $column): array { throw new Exception('Not implemented: ' . __METHOD__); } - public function getTableNames(string $filter = '*', bool $strip = true) + public function getTableNames(string $filter = '*', bool $strip = true): array { throw new Exception('Not implemented: ' . __METHOD__); } - public function tableExists(string $table) + public function tableExists(string $table): bool { throw new Exception('Not implemented: ' . __METHOD__); } - public function fieldList(string $table) + public function fieldList(string $table): array { throw new Exception('Not implemented: ' . __METHOD__); } - public function indexList(string $table) + public function indexList(string $table): array { throw new Exception('Not implemented: ' . __METHOD__); } diff --git a/src/Drivers/PdbPgsql.php b/src/Drivers/PdbPgsql.php index b0ee4a6..b6fcf5d 100644 --- a/src/Drivers/PdbPgsql.php +++ b/src/Drivers/PdbPgsql.php @@ -38,7 +38,7 @@ protected static function afterConnect(PDO $pdo, PdbConfig $config, array $optio /** @inheritdoc */ - public function getPermissions() + public function getPermissions(): array { // TODO Postgres has a slightly different concept about permissions. // The grants are multi-level. Where the database has 'create/drop' @@ -52,7 +52,7 @@ public function getPermissions() /** @inheritdoc */ - public function getTableNames(string $filter = '*', bool $strip = true) + public function getTableNames(string $filter = '*', bool $strip = true): array { $q = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES @@ -90,7 +90,7 @@ public function getTableNames(string $filter = '*', bool $strip = true) /** @inheritdoc */ - public function tableExists(string $table) + public function tableExists(string $table): bool { $q = "SELECT 1 FROM INFORMATION_SCHEMA.TABLES @@ -109,7 +109,7 @@ public function tableExists(string $table) /** @inheritdoc */ - public function fieldList(string $table) + public function fieldList(string $table): array { // TODO primary keys? @@ -196,7 +196,7 @@ public function fieldList(string $table) /** @inheritdoc */ - public function indexList(string $table) + public function indexList(string $table): array { $q = "SELECT indexname, @@ -236,7 +236,7 @@ public function indexList(string $table) /** @inheritdoc */ - public function getForeignKeys(string $table) + public function getForeignKeys(string $table): array { $q = "SELECT k1.constraint_name, @@ -288,7 +288,7 @@ public function getForeignKeys(string $table) /** @inheritdoc */ - public function getDependentKeys(string $table) + public function getDependentKeys(string $table): array { $q = "SELECT k1.constraint_name, @@ -341,14 +341,14 @@ public function getDependentKeys(string $table) /** @inheritdoc */ - public function getTableAttributes(string $table) + public function getTableAttributes(string $table): array { return []; } /** @inheritdoc */ - public function extractEnumArr(string $table, string $column) + public function extractEnumArr(string $table, string $column): array { // TODO // To use CREATE TYPE ENUM ? diff --git a/src/Drivers/PdbSqlite.php b/src/Drivers/PdbSqlite.php index d411725..02d9224 100644 --- a/src/Drivers/PdbSqlite.php +++ b/src/Drivers/PdbSqlite.php @@ -41,7 +41,7 @@ protected static function afterConnect(PDO $pdo, PdbConfig $config, array $optio /** @inheritdoc */ - public function getPermissions() + public function getPermissions(): array { // SQLite doesn't have users/permissions - anything goes. return PdbHelpers::TYPES; @@ -49,7 +49,7 @@ public function getPermissions() /** @inheritdoc */ - public function getTableNames(string $filter = '*', bool $strip = true) + public function getTableNames(string $filter = '*', bool $strip = true): array { $q = "SELECT name FROM sqlite_master @@ -86,7 +86,7 @@ public function getTableNames(string $filter = '*', bool $strip = true) /** @inheritdoc */ - public function tableExists(string $table) + public function tableExists(string $table): bool { self::validateIdentifier($table); @@ -102,7 +102,7 @@ public function tableExists(string $table) /** @inheritdoc */ - public function fieldList(string $table) + public function fieldList(string $table): array { $q = "SELECT \"name\", @@ -151,7 +151,7 @@ public function fieldList(string $table) /** @inheritdoc */ - public function indexList(string $table) + public function indexList(string $table): array { $table = $this->config->prefix . $table; @@ -178,7 +178,7 @@ public function indexList(string $table) /** @inheritdoc */ - public function getForeignKeys(string $table) + public function getForeignKeys(string $table): array { $prefix_table = $this->config->prefix . $table; @@ -204,14 +204,14 @@ public function getForeignKeys(string $table) /** @inheritdoc */ - public function getDependentKeys(string $table) + public function getDependentKeys(string $table): array { throw new Exception('Not implemented: ' . __METHOD__); } /** @inheritdoc */ - public function getTableAttributes(string $table) + public function getTableAttributes(string $table): array { // for autoinc - https://stackoverflow.com/a/33285873/7694753 return []; @@ -219,7 +219,7 @@ public function getTableAttributes(string $table) /** @inheritdoc */ - public function extractEnumArr(string $table, string $column) + public function extractEnumArr(string $table, string $column): array { // https://stackoverflow.com/a/17203007/7694753 $table = $this->config->prefix . $table; diff --git a/src/Pdb.php b/src/Pdb.php index 5465d84..fc57845 100644 --- a/src/Pdb.php +++ b/src/Pdb.php @@ -50,7 +50,7 @@ * * @package karmabunny\pdb */ -abstract class Pdb implements Loggable, Serializable, NotSerializable +abstract class Pdb implements Loggable, Serializable, NotSerializable, PdbDriverInterface { use LoggerTrait; use SerializeTrait; @@ -1431,18 +1431,10 @@ public function recordExists(string $table, array $conditions) // =========================================================== - // Driver specific methods + // Schema methods // =========================================================== - /** - * Get the permissions of the current connection. - * - * @return string[] - */ - public abstract function getPermissions(); - - /** * * @return PdbSchema @@ -1467,27 +1459,6 @@ public function listTables() } - /** - * Fetches the current list of tables. - * - * @param string $filter - * - `''` - (empty) to return all tables - * - `'*'` - to return only tables with the default prefix - * - other - filter on this prefix - * @param bool $strip remove the prefix from the table names - * @return string[] - */ - public abstract function getTableNames(string $filter = '*', bool $strip = true); - - - /** - * - * @param string $table non-prefixed - * @return bool - */ - public abstract function tableExists(string $table); - - /** * * @param string $table non-prefixed @@ -1540,62 +1511,6 @@ public function tableList() } - /** - * - * @param string $table non-prefixed - * @return PdbIndex[] - */ - public abstract function indexList(string $table); - - - /** - * - * @param string $table non-prefixed - * @return PdbColumn[] [ name => PdbColumn ] - */ - public abstract function fieldList(string $table); - - - /** - * Gets all of the columns which have foreign key constraints in a table - * - * @param string $table non-prefixed - * @return PdbForeignKey[] - */ - public abstract function getForeignKeys(string $table); - - - - /** - * Gets all of the dependent foreign key columns (i.e. with the CASCADE delete rule) in other tables - * which link to the id column of a specific table - * - * @param string $table non-prefixed - * @return PdbForeignKey[] - */ - public abstract function getDependentKeys(string $table); - - - /** - * Get adapter specific table information. - * - * @param string $table non-prefixed - * @return array [ key => value] - */ - public abstract function getTableAttributes(string $table); - - - /** - * Returns definition list from column of type ENUM - * - * @param string $table non-prefixed - * @param string $column - * @return string[] - * @throws InvalidArgumentException - */ - public abstract function extractEnumArr(string $table, string $column); - - // =========================================================== // Generic helpers + validators // =========================================================== diff --git a/src/PdbDriverInterface.php b/src/PdbDriverInterface.php new file mode 100644 index 0000000..6c213fa --- /dev/null +++ b/src/PdbDriverInterface.php @@ -0,0 +1,102 @@ + value] + */ + public function getTableAttributes(string $table): array; + + + /** + * Returns definition list from column of type ENUM + * + * @param string $table non-prefixed + * @param string $column + * @return string[] + */ + public function extractEnumArr(string $table, string $column): array; + + + /** + * Fetches the current list of tables. + * + * @param string $filter + * - `''` - (empty) to return all tables + * - `'*'` - to return only tables with the default prefix + * - other - filter on this prefix + * @param bool $strip remove the prefix from the table names + * @return string[] + */ + public function getTableNames(string $filter = '*', bool $strip = true): array; + + + /** + * + * @param string $table non-prefixed + * @return bool + */ + public function tableExists(string $table): bool; + + + /** + * + * @param string $table non-prefixed + * @return PdbColumn[] [ name => PdbColumn ] + */ + public function fieldList(string $table): array; + + + /** + * + * @param string $table non-prefixed + * @return PdbIndex[] + */ + public function indexList(string $table): array; + +} From 92b12e8f3b5d81be02ce146fbf9c60be66702dd5 Mon Sep 17 00:00:00 2001 From: Gwilyn Date: Mon, 1 Sep 2025 17:27:30 +1000 Subject: [PATCH 3/5] Add locking methods for mysql + postgres. --- src/Drivers/PdbMysql.php | 18 ++++++++++++++++ src/Drivers/PdbNoDriver.php | 13 ++++++++++++ src/Drivers/PdbPgsql.php | 42 +++++++++++++++++++++++++++++++++++++ src/Drivers/PdbSqlite.php | 13 ++++++++++++ src/PdbDriverInterface.php | 17 +++++++++++++++ 5 files changed, 103 insertions(+) diff --git a/src/Drivers/PdbMysql.php b/src/Drivers/PdbMysql.php index f7bc201..e8a012a 100644 --- a/src/Drivers/PdbMysql.php +++ b/src/Drivers/PdbMysql.php @@ -404,4 +404,22 @@ public function extractEnumArr(string $table, string $column): array return array_combine($arr, $arr); } + + /** @inheritdoc */ + public function createLock(string $name, float $timeout = 0): bool + { + $key = substr($this->config->database . sha1($name), 0, 63); + $ok = $this->query("SELECT GET_LOCK(?, ?)", [$key, $timeout], 'val?'); + return (bool) $ok; + } + + + /** @inheritdoc */ + public function deleteLock(string $name): bool + { + $key = substr($this->config->database . sha1($name), 0, 63); + $ok = $this->query("SELECT RELEASE_LOCK(?)", [$key], 'val?'); + return (bool) $ok; + } + } diff --git a/src/Drivers/PdbNoDriver.php b/src/Drivers/PdbNoDriver.php index cd60f2d..07c21bd 100644 --- a/src/Drivers/PdbNoDriver.php +++ b/src/Drivers/PdbNoDriver.php @@ -62,4 +62,17 @@ public function indexList(string $table): array throw new Exception('Not implemented: ' . __METHOD__); } + + /** @inheritdoc */ + public function createLock(string $name, float $timeout = 0): bool + { + throw new Exception('Not implemented: ' . __METHOD__); + } + + + /** @inheritdoc */ + public function deleteLock(string $name): bool + { + throw new Exception('Not implemented: ' . __METHOD__); + } } diff --git a/src/Drivers/PdbPgsql.php b/src/Drivers/PdbPgsql.php index b6fcf5d..dfd665b 100644 --- a/src/Drivers/PdbPgsql.php +++ b/src/Drivers/PdbPgsql.php @@ -356,4 +356,46 @@ public function extractEnumArr(string $table, string $column): array return []; } + + /** @inheritdoc */ + public function createLock(string $name, float $timeout = 0): bool + { + [, $key] = unpack('q', sha1($name, true)); + + if ($timeout <= 0) { + $ok = (bool) $this->query("SELECT pg_try_advisory_lock(?)", [$key], 'val?'); + return $ok; + } + else { + $start = microtime(true); + $tick = 50 * 1000; + + for (;;) { + $ok = (bool) $this->query("SELECT pg_try_advisory_lock(?)", [$key], 'val?'); + + if ($ok) { + return true; + } + + // Preventing infinite loops with a timeout. + if (microtime(true) - $start >= $timeout) { + return false; + } + + usleep($tick); + } + + return false; + } + } + + + /** @inheritdoc */ + public function deleteLock(string $name): bool + { + [, $key] = unpack('q', sha1($name, true)); + $ok = $this->query("SELECT pg_advisory_unlock(?)", [$key], 'val?'); + return (bool) $ok; + } + } diff --git a/src/Drivers/PdbSqlite.php b/src/Drivers/PdbSqlite.php index 02d9224..c30a9ac 100644 --- a/src/Drivers/PdbSqlite.php +++ b/src/Drivers/PdbSqlite.php @@ -245,4 +245,17 @@ public function extractEnumArr(string $table, string $column): array return array_combine($arr, $arr); } + + /** @inheritdoc */ + public function createLock(string $name, float $timeout = 0): bool + { + throw new Exception('Not implemented: ' . __METHOD__); + } + + + /** @inheritdoc */ + public function deleteLock(string $name): bool + { + throw new Exception('Not implemented: ' . __METHOD__); + } } diff --git a/src/PdbDriverInterface.php b/src/PdbDriverInterface.php index 6c213fa..923b2a4 100644 --- a/src/PdbDriverInterface.php +++ b/src/PdbDriverInterface.php @@ -99,4 +99,21 @@ public function fieldList(string $table): array; */ public function indexList(string $table): array; + + /** + * + * @param string $name + * @param float $timeout in seconds + * @return bool + */ + public function createLock(string $name, float $timeout = 0): bool; + + + /** + * + * @param string $name + * @return bool + */ + public function deleteLock(string $name): bool; + } From f689f0ea32217b2351f77ebc0ba66c30183d00db Mon Sep 17 00:00:00 2001 From: Gwilyn Date: Mon, 1 Sep 2025 17:28:14 +1000 Subject: [PATCH 4/5] Add pdb mutex with tests. --- src/PdbMutex.php | 72 +++++++++++++++++++++++++++++++++++++++++++ tests/BasePdbCase.php | 49 +++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 src/PdbMutex.php diff --git a/src/PdbMutex.php b/src/PdbMutex.php new file mode 100644 index 0000000..c5fa1f9 --- /dev/null +++ b/src/PdbMutex.php @@ -0,0 +1,72 @@ +pdb = $pdb; + $this->name = $name; + + // Create new sessions to acquire unique locks. + if ($this->uniqueLocks) { + $this->pdb = Pdb::create($this->pdb->config); + } + + register_shutdown_function([$this, '__destruct']); + } + + + /** @inheritdoc */ + public function __destruct() + { + if ($this->autoRelease) { + $this->release(); + } + } + + + /** @inheritdoc */ + public function acquire(float $timeout = 0): bool + { + return $this->pdb->createLock($this->name, $timeout); + } + + + /** @inheritdoc */ + public function release(): bool + { + $ok = $this->pdb->deleteLock($this->name); + + // Release all locks. + if ($ok and $this->releaseAllLocks) { + while ($this->pdb->deleteLock($this->name)); + } + + return $ok; + } +} diff --git a/tests/BasePdbCase.php b/tests/BasePdbCase.php index 86fea84..c9fd53c 100644 --- a/tests/BasePdbCase.php +++ b/tests/BasePdbCase.php @@ -11,6 +11,7 @@ use karmabunny\pdb\Pdb; use karmabunny\pdb\PdbConfig; use karmabunny\pdb\PdbLog; +use karmabunny\pdb\PdbMutex; use karmabunny\pdb\PdbParser; use karmabunny\pdb\PdbSync; use PHPUnit\Framework\TestCase; @@ -559,4 +560,52 @@ public function dataActive(): array 'NOT active' => [false], ]; } + + + protected function createMutex(string $name) + { + return new PdbMutex($this->pdb, $name); + } + + + public function testMutexLock() + { + if ( + !$this->pdb instanceof PdbPgsql + and !$this->pdb instanceof PdbMysql + ) { + $this->markTestSkipped('Skipping mutex tests, not supported.'); + } + + $time = microtime(true); + $lock1 = $this->createMutex('test:1'); + $this->assertTrue($lock1->acquire(0)); + + // No existing lock - no waiting, got a lock. + $this->assertLessThan(0.01, microtime(true) - $time); + + // New lock, no collision, no wait. + $lock2 = $this->createMutex('test:2'); + $this->assertTrue($lock2->acquire(0)); + + // Existing lock, collision, immediate failure. + $time = microtime(true); + $lock3 = $this->createMutex('test:1'); + $this->assertFalse($lock3->acquire(0)); + $this->assertLessThan(0.01, microtime(true) - $time); + + // Existing lock, collision, failure after timeout. + $time = microtime(true); + $lock3 = $this->createMutex('test:1'); + $this->assertFalse($lock3->acquire(0.5)); + $this->assertGreaterThan(0.5, microtime(true) - $time); + + $this->assertTrue($lock1->release()); + + // Try again - with success. + $lock3 = $this->createMutex('test:1'); + $this->assertTrue($lock3->acquire(0)); + $this->assertEquals($lock1->name, $lock3->name); + } + } From a9d68daab1e1a9eee59b57ecce7edf4ee7ee6bb6 Mon Sep 17 00:00:00 2001 From: Gwilyn Date: Wed, 12 Nov 2025 09:55:13 +1100 Subject: [PATCH 5/5] Fix dead code unreached return. --- src/Drivers/PdbPgsql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Drivers/PdbPgsql.php b/src/Drivers/PdbPgsql.php index dfd665b..20ed012 100644 --- a/src/Drivers/PdbPgsql.php +++ b/src/Drivers/PdbPgsql.php @@ -379,7 +379,7 @@ public function createLock(string $name, float $timeout = 0): bool // Preventing infinite loops with a timeout. if (microtime(true) - $start >= $timeout) { - return false; + break; } usleep($tick);