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#3045) ManagedEntities - Fix crash during upgrade #22642

Merged
merged 1 commit into from
Feb 1, 2022

Conversation

colemanw
Copy link
Member

Overview

This prevents a potential crash when trying to update a column before it has been added by the upgrader

Fixes dev/core#3045

This prevents a potential crash when trying to update a column before it has been added by the upgrader

Fixes dev/core#3045
@civibot
Copy link

civibot bot commented Jan 27, 2022

(Standard links)

@civibot civibot bot added the master label Jan 27, 2022
@colemanw colemanw changed the base branch from master to 5.46 January 27, 2022 17:22
@civibot civibot bot added 5.46 and removed master labels Jan 27, 2022
@totten totten changed the title ManagedEntities - Fix crash during upgrade (dev/core#3045) ManagedEntities - Fix crash during upgrade Jan 28, 2022
@totten
Copy link
Member

totten commented Jan 28, 2022

Part A

I've been trying to replicate the report... I installed 5.33 and tried doing all these things to the initial 5.33 DB:

  • Add new extension and run civix generate:report (to create a managed entity)
  • Create smart groups via traditional search. One just filtering on name; one filtering on event start date.
  • Install search. Created a saved search searchkit UI.
  • Install deduper, extendedreport. (They show up in some of the reports.)
  • Hack civicrm_managed and deduper so that one of the installed extensions appears to take ownership of my manually-created saved-search.

Then I ran DB upgrades -- with both the web-based upgrader and cv upgrade:db (cv v0.3.15).

Part B

Something in the backtrace and patch is confusing to me -- it appears to be firing hook_civicrm_post during incremental schema-updates. The dispatch policy is to shush hooks during incremental schema-updates. (Precisely because external hook listeners generally aren't attuned -- and generally cannot be attuned -- to all the wonky interim states of an upgrading DB...)

While trying to r-run above, I also edited CRM_Core_BAO_Managed::on_hook_civicrm_post to log whenever it's called, and it wasn't called. This could just be that I haven't understood the data/configuration needed to reproduce (see Part A) -- or it could be that it's not fired normally, and that there's some special circumstance which causes it fire unexpectedly.

I struggle to see how the backtrace would arise. - or how the patch here could be operative. Maybe the system has additional/inter-related patches? Maybe it's an old version of cv that doesn't respect the dispatch-policy? Maybe it's a different upgrader? (I don't know -- I'm just throwing spaghetti at the wall.)

Part C

On a concrete level, I can't reproduce; on an abstract level, I don't understand. So... I don't really have enough to go on for merging...

Of course, if someone else can test/reproduce, then that's cool...

@colemanw
Copy link
Member Author

@totten your first step may be the problem. civix generate:report will make a managed record but not an APIv4 ManagedEntity type. Those include ContactType, CustomField, CustomGroup, Dashboard, Group, MembershipStatus, MembershipType, Navigation, OptionGroup, OptionValue, PaymentProcessorType, RelationshipType, SavedSearch & SearchDisplay.

@totten
Copy link
Member

totten commented Jan 28, 2022

@colemanw Yes, that's a valid point about the first attempt. But it doesn't explain the third attempt (since 5.33's search registered mgd's that use OptionGroup and OptionValue), and it doesn't explain the fifth attempt (which had mgd for a SavedSearch record).

(Note: My bulleted list may have been a little confusing -- it wasn't really "first step; second step" in a procedure. It was more like: "I tried one approach, and it didn't work; then I tried a second approach, which also didn't work". Basically, after every intervention, I re-ran the upgrade - and the upgrade ran fine - so I'd move on to try another approach.)

@seamuslee001
Copy link
Contributor

I'm going to merge based on the review on #22643 from 2 separate community members saying this fixed problems for them

@seamuslee001 seamuslee001 merged commit ffd8779 into civicrm:5.46 Feb 1, 2022
@seamuslee001 seamuslee001 deleted the fixManagedCrash branch February 1, 2022 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants