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 infinite loop on Civi 5.44+ #19

Merged
merged 1 commit into from
Dec 27, 2021
Merged

Conversation

MegaphoneJon
Copy link
Contributor

This extension causes an infinite loop (w/ eventual OOM error or segfault) anywhere it's called in Civi 5.44+. civicrm/civicrm-core#21429 is the culprit, registerTokens() now calls a new function getLegacyHookTokens().

Static vars aren't pretty but this extension already uses one, and it gets the job done.

To replicate this, go to any mailing screen (including a quick email) on 5.44+ with this extension enabled.

@twomice
Copy link
Owner

twomice commented Dec 9, 2021

Thanks @MegaphoneJon . Will review and (hopefully) merge soon.

@twomice
Copy link
Owner

twomice commented Dec 27, 2021

Testing this PR indicates that it solves the problem described #18:

CiviCRM version 5.44.0
Extension version: master 84a3b88 (version "0.3")

Before:

  1. Navigate to https://example.com/civicrm/activity/email/add?action=add&reset=1&cid=N&selectedChild=activity&atype=3, where N is the ID of any contact with an email address. (This is the same URL you'd reach by navigating to the contact and selecting Actions > Send an Email. It helps to use this URL directly, or else to use your browser's "Open Link In New Tab" feature so as to see any error messages easily. It also help to have civicrm's debugging features enabled.)
  2. Observe a fatal error of some kind. On my system, the OOM error is precluded by xdebug's detection of possible infinite loop. My system reports this error:
Error messageError: Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '256' frames in Civi\Token\ImpliedContextSubscriber->getMappings() (line 105 of /[drupal-docroot]/sites/all/modules/civicrm/Civi/Token/ImpliedContextSubscriber.php).

After:

  1. Repeat step 1 above.
  2. Observe the "Send an Email" form loads without error. Also observe that the expected relationship-based tokens are available in the Tokens drop-down.

I'm merging and closing. Thanks @MegaphoneJon !

@twomice twomice merged commit 4d1df72 into twomice:master Dec 27, 2021
@destrieux destrieux mentioned this pull request Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants