eileenmcnaughton / nz.co.fuzion.csvimport

Import to API using csv GUI
GNU Affero General Public License v3.0
8 stars 27 forks source link

Fixes fatal error when opening the API Import page - PHP message: PHP Fatal error: Uncaught Error: Call to undefined method CRM_Core_BAO_Note::entityTables() #41

Closed agileware-justin closed 3 years ago

agileware-justin commented 3 years ago

Fixes fatal error when opening the API Import page. Fixes #40 and possibly #30 too

Error message: PHP message: PHP Fatal error: Uncaught Error: Call to undefined method CRM_Core_BAO_Note::entityTables()

CiviCRM 5.40.1

Agileware Ref: CIVICRM-1819

eileenmcnaughton commented 3 years ago

@colemanw - looks like we should have deprecated rather than removed this function ideally https://github.com/civicrm/civicrm-core/commit/8ced16c78b3d086cbd303117ebac085348c91df6 - still it's not supported to be called outside of core

@agileware-justin we should probably use the api call rather than use a hard coded list - it looks like this is the right api call - I can update info.xml to 5.40 & tag a release to handle the compatibility issue

$fields = \Civi\Api4\Note::getFields()
  ->setLoadOptions(TRUE)
  ->addSelect('options')
  ->addWhere('name', '=', 'entity_table')
  ->execute();
foreach ($fields as $field) {
  // do something
}

image

colemanw commented 3 years ago

still it's not supported to be called outside of core

No, definitely not in any way shape or form was that supported to be called outside of core. Fun fact, though. Switching to the API call is both forward and backward compatible as core will get the pseudoconstant from wherever it happens to be stored (depending on the civi version).

agileware-justin commented 3 years ago

Closing in favour of alternative #42