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#3502 - CiviEventDispatcher - Softer errors for not-ready. More comments. #23785

Merged
merged 2 commits into from
Jun 14, 2022

Conversation

totten
Copy link
Member

@totten totten commented Jun 14, 2022

Overview

v5.50 is more likely to raise complaints about hooks that fire during bootstrap (as in the case of https://lab.civicrm.org/dev/core/-/issues/3502). This patch tries to turn-down the volume on such errors.

(This is the 5.51-rc variant of the patch. Stable patch is #23739.)

Before

  • Throws exception.

After

  • Shows a message to the web-user (trigger_error(...E_USER_WARNING))
  • Logs a message for sysadmin (error_log()) with backtrace.

Comments

Two use-cases:

  1. The easiest way to trigger an error is to hack boot() function, eg

     \CRM_Utils_Hook::singleton()->commonBuildModuleList('civicrm_boot');
    +\CRM_Utils_Hook::entityTypes($x);
     $bootServices['dispatcher.boot']->setDispatchPolicy($mainDispatchPolicy);
  2. I also managed to [reproduce the same error as @francescbassas](https://lab.civicrm.org/dev/core/-/issues/3502#note_75272. Activating rules wasn't enough -- I needed also needed a rule to specifically react to logs.

@civibot
Copy link

civibot bot commented Jun 14, 2022

(Standard links)

@totten
Copy link
Member Author

totten commented Jun 14, 2022

Merge based on testing for the 5.50 variant.

@totten totten merged commit 99f0a8f into civicrm:5.51 Jun 14, 2022
@totten totten deleted the 5.51-hook-log branch June 14, 2022 21:11
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.

1 participant