From 633a8dbc55d69407213b40e9934355d03c1babbf Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 12 Aug 2020 22:01:24 -0400 Subject: [PATCH] Suppress errors when reading DAO version constants --- CRM/Core/DAO.php | 6 +++--- Civi/Api4/Generic/Traits/CustomValueActionTrait.php | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index d410b1e270..0cc0775f38 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -552,7 +552,7 @@ class CRM_Core_DAO extends DB_DataObject { // Exclude fields yet not added by pending upgrades $dbVer = \CRM_Core_BAO_Domain::version(); - $daoExt = constant(static::class . '::EXT'); + $daoExt = defined(static::class . '::EXT') ? constant(static::class . '::EXT') : NULL; if ($fields && $daoExt === 'civicrm' && version_compare($dbVer, \CRM_Utils_System::version()) < 0) { $fields = array_filter($fields, function($field) use ($dbVer) { $add = $field['add'] ?? '1.0.0'; @@ -1161,8 +1161,8 @@ class CRM_Core_DAO extends DB_DataObject { if (CRM_Utils_System::version() === CRM_Core_BAO_Domain::version()) { return TRUE; } - $daoExt = constant(static::class . '::EXT'); - $daoVersion = constant(static::class . '::TABLE_ADDED') ?? '1.0'; + $daoExt = defined(static::class . '::EXT') ? constant(static::class . '::EXT') : NULL; + $daoVersion = defined(static::class . '::TABLE_ADDED') ? constant(static::class . '::TABLE_ADDED') : '1.0'; return !($daoExt === 'civicrm' && version_compare(CRM_Core_BAO_Domain::version(), $daoVersion, '<')); } diff --git a/Civi/Api4/Generic/Traits/CustomValueActionTrait.php b/Civi/Api4/Generic/Traits/CustomValueActionTrait.php index 78065d55f3..acf2bd70a4 100644 --- a/Civi/Api4/Generic/Traits/CustomValueActionTrait.php +++ b/Civi/Api4/Generic/Traits/CustomValueActionTrait.php @@ -106,4 +106,11 @@ trait CustomValueActionTrait { return $this->customGroup; } + /** + * @return \CRM_Core_DAO|string + */ + protected function getBaoName() { + return \CRM_Core_BAO_CustomValue::class; + } + } -- 2.25.1