Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix import class loading issue in entityTypes hook #24621

Merged
merged 1 commit into from
Sep 27, 2022

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Sep 26, 2022

Overview

Fix import class loading issue in entityTypes hook

Before

My prod site with civiimport enabled just crashed with a class loading error (I don't have the full backtrace - this is the part that was emailed to me. The class exists but must not have autoloaded yet

Error Details

An error of type E_ERROR was caused in line 86 of the file /wp-content/plugins/civicrm/civicrm/ext/civiimport/civiimport.php. Error message: Uncaught Error: Class 'Civi\BAO\Import' not found in /wp-content/plugins/civicrm/civicrm/ext/civiimport/civiimport.php:86
Stack trace:
#0 /wp-content/plugins/civicrm/civicrm/CRM/Utils/Hook.php(271): civiimport_civicrm_entityTypes()
#1 /wp-content/plugins/civicrm/civicrm/CRM/Utils/Hook/WordPress.php(136): CRM_Utils_Hook->runHooks()
#2 /wp-content/plugins/civicrm/civicrm/Civi/Core/CiviEventDispatcher.php(256): CRM_Utils_Hook_WordPress->invokeViaUF()
#3 /wp-content/plugins/civicrm/civicrm/vendor/symfony/event-dispatcher/EventDispatcher.php(264): Civi\Core\CiviEventDispatcher::delegateToUF()
#4 /wp-content/plugins/civicrm/civicrm/vendor/symfony/event-dispatcher/EventDispatcher.php(239): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch()
#5 /wp-content/plugins/civicrm/civicrm/vendor/symfo

After

Site loads

Technical Details

entityTypes hooks notoriously loads early & can be tricky because of that - this simplifies the code called from there not to rely on extension class loading being already working

Comments

@civibot
Copy link

civibot bot commented Sep 26, 2022

(Standard links)

@civibot civibot bot added the 5.54 label Sep 26, 2022
@eileenmcnaughton eileenmcnaughton force-pushed the import_class_loader branch 3 times, most recently from 963083a to faaa69d Compare September 26, 2022 23:12
@colemanw
Copy link
Member

Looks good. MOP.

@eileenmcnaughton eileenmcnaughton merged commit 5ba0767 into civicrm:5.54 Sep 27, 2022
@eileenmcnaughton eileenmcnaughton deleted the import_class_loader branch September 27, 2022 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants