Fix import class loading issue in entityTypes hook #24621
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 yetError 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 workingComments