Answers.Body: <p>Found the problem. This is a multisite setup, and only one site has the custom plugin installed. So my hacking the Mailing/Event/BAO/Unsubscribe.php made one of the sites fail when it reached the call to the function defined in the custom plugin—but it couldn't find the function.</p>
  
  <p>I didn't realize that the cron error emails I was receiving were for a different site than the one I tested manually. Hence my confusion about success manually running the Fetch Bounces job, but errors when it ran via cron.</p>
  
  <p>Regarding the proximate trigger/cause: since I was logged in and saw the prompt to do so, I upgraded CiviRules at the same time I sent a new mailing. The new mailing bounced to two addresses, which caused the Fetch Bounces job to attempt to process them. I mistakenly thought there were no emails awaiting bounce processing, because, again, I was looking at the bounce email account for the wrong site. That seemed to point to the CiviRules update having done something strange.</p>
  
  <p>So CiviRules probably had nothing to do with it... But I am still slightly confused, because I'm pretty sure there were bounce emails needing processing even before my simultaneous CiviRules upgrade/sending a new mailing. Before that change, the Scheduled Jobs log for Fetch Bounces shows:</p>
  
  <blockquote>
    <p>Finished execution of Fetch Bounces with result: Failure, Error message: A fatal error was triggered: Could not connect to MailStore for return@ourdomain.org@mail.ourdomain.orgError message: An error occured while sending or recei (...)</p>
  </blockquote>
  
  <p>And I wasn't receiving cron error emails to let me know it was failing. After the update/mailing send, the job log shows Start, but never any Finish entries. So it seems my core hack broke it a while ago, but that either the CiviRules update, or my sending a new mailing, changed the way in which it failed.</p>
  
  <p>Anyway, I'm glad it's not bombarding me with error emails now, and that it's actually processing bounces. People who find this issue can enjoy my classic PEBKAC (Problem Exists Between Keyboard And Chair)!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-14T06:32:21.120Z
Answers.Text: Glad you found it, and glad CiviRules was not at the root of this :-)
Answers.UserDisplayName: ErikH - CiviCooP
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-14T03:08:39.297Z
Answers.LastActivityDate: 2019-08-14T03:08:39.297Z
Answers.UserDisplayName: Norris
Body: <p>Yesterday, I updated the CiviRules extension to version 2.8, then did the database update. Immediately afterward, I began getting error emails each time the cron job runs. </p>
  
  <p>I have in place a hack to <code>civicrm/CRM/Mailing/Event/BAO/Unsubscribe.php</code>, to load a language-appropriate template for the unsubscribe email sent out. I don't think the details are important here, but the hack calls a function <code>get_multilingual_template()</code>, which is defined in a custom extension.</p>
  
  <p>The error emails I receive read:</p>
  
  <pre><code>PHP Fatal error:  Uncaught Error: Call to undefined function get_multilingual_template() in /var/www/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Mailing/Event/BAO/Unsubscribe.php:379
  Stack trace:
  #0 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/api/v3/MailingEventUnsubscribe.php(52): CRM_Mailing_Event_BAO_Unsubscribe::send_unsub_response('5051', Array, false, '336')
  #1 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(101): civicrm_api3_mailing_event_unsubscribe_create(Array)
  #2 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(168): Civi\API\Provider\MagicFunctionProvider-&gt;invoke(Array)
  #3 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(99): Civi\API\Kernel-&gt;runRequest(Array)
  #4 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/api/api.php(23): Civi\API\Kernel-&gt;runSafe('mailing_event_u...', 'create', Array, NULL)
  #5 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/api/v3/MailingGroup.php(62): civicrm_api('ma in /var/www/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Mailing/Event/BAO/Unsubscribe.php on line 379
  Fatal error: Uncaught Error: Call to undefined function get_multilingual_template() in /var/www/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Mailing/Event/BAO/Unsubscribe.php:379
  Stack trace:
  #0 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/api/v3/MailingEventUnsubscribe.php(52): CRM_Mailing_Event_BAO_Unsubscribe::send_unsub_response('5051', Array, false, '336')
  #1 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(101): civicrm_api3_mailing_event_unsubscribe_create(Array)
  #2 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(168): Civi\API\Provider\MagicFunctionProvider-&gt;invoke(Array)
  #3 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(99): Civi\API\Kernel-&gt;runRequest(Array)
  #4 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/api/api.php(23): Civi\API\Kernel-&gt;runSafe('mailing_event_u...', 'create', Array, NULL)
  #5 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/api/v3/MailingGroup.php(62): civicrm_api('ma in /var/www/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Mailing/Event/BAO/Unsubscribe.php on line 379
  Error: The site is experiencing technical difficulties.
  </code></pre>
  
  <p>The cron command is:</p>
  
  <p><code>/usr/local/bin/wp --user=civicron --url=https://oursite.org/ --require=/var/www/wordpress/wp-content/plugins/civicrm/wp-cli/civicrm.php --path=/var/www/wordpress civicrm api job.execute &gt; /dev/null</code></p>
  
  <p>So it seems that somehow the CiviRules update made the cron run fail to load our custom extension? I don't know why it's even trying to call get_multilingual_template(), since as far as I can tell, nothing should be triggering an Unsubscribe attempt. (And unsubscribe by email still worked anyway, when I tested it and the cron job ran, generating the same error but correctly unsubscribing my test account.)</p>
  
  <p>I don't know to what the 5051 or 336 numbers in the send_unsub_response refer.</p>
  
  <p>Looking at the scheduled jobs admin page, each task is run as expected, and each job shows a Finished status of "success."</p>
  
  <p>I tried disabling and reenabling both CiviRules and our custom extension. I don't know what else to look at, or to try from here. Thanks for any suggestions!</p>
  
Tags: <cron><cron-job><civirules><multisite>
Title: CiviRules update interfering with another plugin?
ThreadText: # CiviRules update interfering with another plugin?
  
  (Asked by: username_0 on 2019-08-09)
  
  Yesterday, I updated the CiviRules extension to version 2.8, then did the database update. Immediately afterward, I began getting error emails each time the cron job runs.
  
  I have in place a hack to `civicrm/CRM/Mailing/Event/BAO/Unsubscribe.php`, to load a language-appropriate template for the unsubscribe email sent out. I don't think the details are important here, but the hack calls a function `get_multilingual_template()`, which is defined in a custom extension.
  
  The error emails I receive read:
  
  ```
  PHP Fatal error:  Uncaught Error: Call to undefined function get_multilingual_template() in /var/www/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Mailing/Event/BAO/Unsubscribe.php:379
  Stack trace:
  #0 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/api/v3/MailingEventUnsubscribe.php(52): CRM_Mailing_Event_BAO_Unsubscribe::send_unsub_response('5051', Array, false, '336')
  #1 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(101): civicrm_api3_mailing_event_unsubscribe_create(Array)
  #2 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(168): Civi\API\Provider\MagicFunctionProvider->invoke(Array)
  #3 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(99): Civi\API\Kernel->runRequest(Array)
  #4 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/api/api.php(23): Civi\API\Kernel->runSafe('mailing_event_u...', 'create', Array, NULL)
  #5 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/api/v3/MailingGroup.php(62): civicrm_api('ma in /var/www/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Mailing/Event/BAO/Unsubscribe.php on line 379
  Fatal error: Uncaught Error: Call to undefined function get_multilingual_template() in /var/www/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Mailing/Event/BAO/Unsubscribe.php:379
  Stack trace:
  #0 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/api/v3/MailingEventUnsubscribe.php(52): CRM_Mailing_Event_BAO_Unsubscribe::send_unsub_response('5051', Array, false, '336')
  #1 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(101): civicrm_api3_mailing_event_unsubscribe_create(Array)
  #2 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(168): Civi\API\Provider\MagicFunctionProvider->invoke(Array)
  #3 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(99): Civi\API\Kernel->runRequest(Array)
  #4 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/api/api.php(23): Civi\API\Kernel->runSafe('mailing_event_u...', 'create', Array, NULL)
  #5 /var/www/wordpress/wp-content/plugins/civicrm/civicrm/api/v3/MailingGroup.php(62): civicrm_api('ma in /var/www/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Mailing/Event/BAO/Unsubscribe.php on line 379
  Error: The site is experiencing technical difficulties.
  
  ```
  
  The cron command is:
  
  `/usr/local/bin/wp --user=civicron --url=https://oursite.org/ --require=/var/www/wordpress/wp-content/plugins/civicrm/wp-cli/civicrm.php --path=/var/www/wordpress civicrm api job.execute > /dev/null`
  
  So it seems that somehow the CiviRules update made the cron run fail to load our custom extension? I don't know why it's even trying to call get\_multilingual\_template(), since as far as I can tell, nothing should be triggering an Unsubscribe attempt. (And unsubscribe by email still worked anyway, when I tested it and the cron job ran, generating the same error but correctly unsubscribing my test account.)
  
  I don't know to what the 5051 or 336 numbers in the send\_unsub\_response refer.
  
  Looking at the scheduled jobs admin page, each task is run as expected, and each job shows a Finished status of "success."
  
  I tried disabling and reenabling both CiviRules and our custom extension. I don't know what else to look at, or to try from here. Thanks for any suggestions!
  
  **Tags:** cron, cron-job, civirules, multisite
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-08-14. Score: 1 | Accepted answer
  
  Found the problem. This is a multisite setup, and only one site has the custom plugin installed. So my hacking the Mailing/Event/BAO/Unsubscribe.php made one of the sites fail when it reached the call to the function defined in the custom plugin—but it couldn't find the function.
  
  I didn't realize that the cron error emails I was receiving were for a different site than the one I tested manually. Hence my confusion about success manually running the Fetch Bounces job, but errors when it ran via cron.
  
  Regarding the proximate trigger/cause: since I was logged in and saw the prompt to do so, I upgraded CiviRules at the same time I sent a new mailing. The new mailing bounced to two addresses, which caused the Fetch Bounces job to attempt to process them. I mistakenly thought there were no emails awaiting bounce processing, because, again, I was looking at the bounce email account for the wrong site. That seemed to point to the CiviRules update having done something strange.
  
  So CiviRules probably had nothing to do with it... But I am still slightly confused, because I'm pretty sure there were bounce emails needing processing even before my simultaneous CiviRules upgrade/sending a new mailing. Before that change, the Scheduled Jobs log for Fetch Bounces shows:
  
  > Finished execution of Fetch Bounces with result: Failure, Error message: A fatal error was triggered: Could not connect to MailStore for return@ourdomain.org@mail.ourdomain.orgError message: An error occured while sending or recei (...)
  
  And I wasn't receiving cron error emails to let me know it was failing. After the update/mailing send, the job log shows Start, but never any Finish entries. So it seems my core hack broke it a while ago, but that either the CiviRules update, or my sending a new mailing, changed the way in which it failed.
  
  Anyway, I'm glad it's not bombarding me with error emails now, and that it's actually processing bounces. People who find this issue can enjoy my classic PEBKAC (Problem Exists Between Keyboard And Chair)!
  
  > **Comments:**
  > **username_1**: Glad you found it, and glad CiviRules was not at the root of this :-)  
  
  ---
  
  