From 4c1bd923529d3e8fdf31c079c9e39edea08c6625 Mon Sep 17 00:00:00 2001 From: Patrick Figel Date: Tue, 5 Feb 2019 17:58:15 +0100 Subject: [PATCH] CRM/Core - Fix isCoreTable to check for tables instead of classes This fixes CRM_Core_DAO_AllCoreTables::isCoreTable to check for the existence of tables instead of DAO classes. The method is used only once in core, and the intention there is to look for table names, so there should not be much risk of breakage. --- CRM/Core/DAO/AllCoreTables.php | 2 +- tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CRM/Core/DAO/AllCoreTables.php b/CRM/Core/DAO/AllCoreTables.php index 4d74ea35d3..03060e11a6 100644 --- a/CRM/Core/DAO/AllCoreTables.php +++ b/CRM/Core/DAO/AllCoreTables.php @@ -198,7 +198,7 @@ class CRM_Core_DAO_AllCoreTables { * @return bool */ public static function isCoreTable($tableName) { - return FALSE !== array_search($tableName, self::tables()); + return array_key_exists($tableName, self::tables()); } /** diff --git a/tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php b/tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php index 7503e5a106..2ad560ec98 100644 --- a/tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php +++ b/tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php @@ -204,4 +204,12 @@ class CRM_Core_DAO_AllCoreTablesTest extends CiviUnitTestCase { $this->assertEquals($newIndices, $expectedIndices); } + /** + * Test CRM_Core_DAO_AllCoreTables::isCoreTable + */ + public function testIsCoreTable() { + $this->assertTrue(CRM_Core_DAO_AllCoreTables::isCoreTable('civicrm_contact'), 'civicrm_contact should be a core table'); + $this->assertFalse(CRM_Core_DAO_AllCoreTables::isCoreTable('civicrm_invalid_table'), 'civicrm_invalid_table should NOT be a core table'); + } + } -- 2.25.1