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

(dev/core#3496) Missing extension leads to bootstrap error for "hook_civicrm_entityTypes" #23716

Merged
merged 1 commit into from
Jun 8, 2022

Conversation

totten
Copy link
Member

@totten totten commented Jun 8, 2022

Overview

If you attempt to load CiviCRM 5.50 on a site with a missing/badly-uninstalled extension, then it crashes.

See also: https://lab.civicrm.org/dev/core/-/issues/3496

(This PR is against 5.50-stable. For 5.51+, see #23718.)

Steps to reproduce

  • Install 5.50
  • Enable an extension
  • Delete the extension
  • Try to open any page (where CiviCRM is active)

Before

All page-loads fail due to unhandled exception:

CiviCRM has not bootstrapped sufficiently to fire event "hook_civicrm_entityTypes"

After

CiviCRM is able to continue running. Of course, you should disable the missing extension completely.

Technical Details

The discussion on Stackexchange/Gitlab highlights the presence of civicrm_entity; however, I think this is incidental. I installed on D9/Civi 5.49/civicrm_entity and then upgraded to Civi 5.50 -- and did not encounter the problem. Additionally, one commenter mentioned a similar problem on WordPress (which means they don't have civicrm_entity). So I don't think it's causal -- but having civicrm_entity might amplify the problem (eg because it boots Civi more often).

There are two interesting backtraces - one is a screenshot from the Gitlab issue, and the other was pasted into MM by @mattwire. There's a common element in both. Here's an annotated excerpt from Matt's:

>> Segment A -- It's attempting to read `civicrm_extension` via DAO, 
>> but that demands lots of metadata/hooks. 

#0 /path/to/web/sites/all/modules/civicrm/Civi/Core/CiviEventDispatcher.php(190): CRM_Core_Error::backtrace()
#1 /path/to/web/sites/all/modules/civicrm/CRM/Utils/Hook.php(167): Civi\Core\CiviEventDispatcher->dispatch("hook_civicrm_entityTypes", Object(Civi\Core\Event\GenericHookEvent))
#2 /path/to/web/sites/all/modules/civicrm/CRM/Utils/Hook.php(2199): CRM_Utils_Hook->invoke((Array:1), (Array:154), NULL, NULL, NULL, NULL, NULL, "civicrm_entityTypes")
#3 /path/to/web/sites/all/modules/civicrm/CRM/Core/DAO/AllCoreTables.php(38): CRM_Utils_Hook::entityTypes((Array:154))
#4 /path/to/web/sites/all/modules/civicrm/CRM/Core/DAO/AllCoreTables.php(476): CRM_Core_DAO_AllCoreTables::init()
#5 /path/to/web/sites/all/modules/civicrm/CRM/Core/DAO/Extension.php(259): CRM_Core_DAO_AllCoreTables::invoke("CRM_Core_DAO_Extension", "fields_callback", (Array:8))
#6 /path/to/web/sites/all/modules/civicrm/CRM/Core/DAO.php(613): CRM_Core_DAO_Extension::fields()
#7 /path/to/web/sites/all/modules/civicrm/packages/DB/DataObject.php(419): CRM_Core_DAO->table()

>> Segment B -- It's using an unusual function `createInfoFromDB()`; 
>> this function only runs if you have a missing extension

#8 /path/to/web/sites/all/modules/civicrm/CRM/Extension/Manager.php(717): DB_DataObject->find(TRUE)
#9 /path/to/web/sites/all/modules/civicrm/CRM/Extension/Mapper.php(180): CRM_Extension_Manager->createInfoFromDB("com.skvare.cmsuser")
#10 /path/to/web/sites/all/modules/civicrm/CRM/Extension/Mapper.php(216): CRM_Extension_Mapper->keyToInfo("com.skvare.cmsuser")
#11 /path/to/web/sites/all/modules/civicrm/CRM/Extension/Mapper.php(329): CRM_Extension_Mapper->keyToPath("com.skvare.cmsuser")

So I was able to reproduce by the error by deleting an active extension.

@civibot
Copy link

civibot bot commented Jun 8, 2022

(Standard links)

@seamuslee001
Copy link
Contributor

added MOP based on testing in mattermost https://chat.civicrm.org/civicrm/pl/t8gynpkr4bb9dbirzh5numeq8e

@jrobens
Copy link

jrobens commented Jun 8, 2022

I can confirm that making the changes in this patch to the code allows the site to load.

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.

3 participants