From 6743de63f5d0d276d6ee6bfa0d065b7f289f48ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Mon, 20 Jun 2022 08:18:53 +0200 Subject: [PATCH] Changed: - DBA::exists() should only be used for checking if records exists. - if you want to check if a table exists, please ALWAYS use DBStructure::existsTable() instead --- src/Database/DBA.php | 4 ++-- tests/src/Database/DBATest.php | 3 --- tests/src/Database/DBStructureTest.php | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Database/DBA.php b/src/Database/DBA.php index d7c0421b7a..e519a63cd6 100644 --- a/src/Database/DBA.php +++ b/src/Database/DBA.php @@ -218,8 +218,8 @@ class DBA /** * Check if data exists * - * @param string|array $table Table name or array [schema => table] - * @param array $condition array of fields for condition + * @param string|array $table Table name or array [schema => table] + * @param array $condition array of fields for condition * @return boolean Are there rows for that condition? * @throws \Exception */ diff --git a/tests/src/Database/DBATest.php b/tests/src/Database/DBATest.php index c92133ac54..febe9c8c62 100644 --- a/tests/src/Database/DBATest.php +++ b/tests/src/Database/DBATest.php @@ -55,9 +55,6 @@ class DBATest extends DatabaseTest self::assertTrue(DBA::exists('config', [])); self::assertFalse(DBA::exists('notable', [])); - self::assertTrue(DBA::exists('config', null)); - self::assertFalse(DBA::exists('notable', null)); - self::assertTrue(DBA::exists('config', ['k' => 'hostname'])); self::assertFalse(DBA::exists('config', ['k' => 'nonsense'])); } diff --git a/tests/src/Database/DBStructureTest.php b/tests/src/Database/DBStructureTest.php index 638a98ed7a..613e2f7832 100644 --- a/tests/src/Database/DBStructureTest.php +++ b/tests/src/Database/DBStructureTest.php @@ -45,7 +45,6 @@ class DBStructureTest extends DatabaseTest */ public function testExists() { self::assertTrue(DBStructure::existsTable('config')); - self::assertFalse(DBStructure::existsTable('notatable')); self::assertTrue(DBStructure::existsColumn('config', ['k']));