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 config is null on hooks #26178

Merged
merged 1 commit into from
May 9, 2023
Merged

Conversation

stesi561
Copy link
Contributor

@stesi561 stesi561 commented May 9, 2023

Overview

Encountered error when expecting config to be initialised when using hook_civicrm_config.

Found due to https://github.com/eileenmcnaughton/nz.co.fuzion.civixero/blob/bfa6ec6e0d1906fe9b96e0d364e6a19d7b453331/Civixero.php#L16

which defines the hook as:
function civixero_civicrm_config(CRM_Core_Config $config) {

Seems like in the D7 code config is initialised but somewhere along the way this didn't make it do D8.

https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config/

Before

hook_civicrm_config is called with null, resulting in a Fatal error if nz.co.fuzion.civixero extension latest version is installed.

After

hook_civicrm_config is called with config object.

@civibot
Copy link

civibot bot commented May 9, 2023

(Standard links)

@civibot civibot bot added the master label May 9, 2023
@eileenmcnaughton
Copy link
Contributor

@totten can you check this - the other CMS pass config through - these 2 don't as it turns out.... and haven't - so 'fixing' could have unexpected consquences ... maybe

@totten
Copy link
Member

totten commented May 9, 2023

@eileenmcnaughton @stesi561 - I would be optimistic about this change. If there were some edge-case where an extension only worked at moment when $config===NULL, then it probably would've been broken already (from the POV of D7/WP/BD/J).

For due diligence, I've fired a test-run on top of D9 (https://test.civicrm.org/job/CiviCRM-Manual-Test/67/parameters/). One might also do some light r-run with cv (since that's one of the few places where it's still possible to hit loadBootStrap on D8+)

@eileenmcnaughton
Copy link
Contributor

OK - let's merge it - it does make me wonder if we really need to pass out the config object - but whatever

@eileenmcnaughton eileenmcnaughton merged commit d378a8f into civicrm:master May 9, 2023
@stesi561 stesi561 deleted the drupalconfig branch May 10, 2023 01:19
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