Page MenuHomeIn-Portal Phabricator

INP-1710 - [bc fix] Asynchronous e-mail sending by default
ClosedPublic

Authored by alex on Jul 3 2017, 5:07 AM.

Details

Test Plan

Preparations

  1. enable Debug Mode (because deprecation notices are only written in debug mode)
  2. enable System Log and set its log level to include Notices
  3. login to Admin Console
  4. go to ConfigurationWebsiteAdvanced section
  5. enable Use Cron to run Scheduled Tasks setting and save changes
  6. go to ConfigurationWebsiteScheduled Tasks section
  7. disable all scheduled tasks (Select All > Decline)
  8. enable scheduled task with email-queue:OnProcess event
  9. go to User ManagementMailings section and click on Email Queue tab
  10. if there are records present in grid, then delete them
  11. go to User ManagementUsers section
  12. create approved user record

Part 1 (existing code, system setting = queue, ajax)

  1. login to Admin Console
  2. go to ConfigurationWebsiteAdvanced section
  3. set Email Delivery setting to Email Queue and save changes
  4. go to User ManagementUsers section
  5. press Approve or Decline toolbar button to invert user status
  6. go to User ManagementMailings section and click on Email Queue tab
  7. confirm, that:
    • a record for user status change email was created
    • email wasn't sent yet to user's email address
  8. press Process Queue toolbar button
  9. confirm, that:
    • a record for user status change email was removed
    • email was sent to user's email address
  10. go to {Logs & Reports > System Log} section
  11. confirm, that no new records about deprecations were created

Part 2 (existing code, system setting = immediate, ajax)

  1. login to Admin Console
  2. go to ConfigurationWebsiteAdvanced section
  3. set Email Delivery setting to Immediate and save changes
  4. go to User ManagementUsers section
  5. press Approve or Decline toolbar button to invert user status
  6. go to User ManagementMailings section and click on Email Queue tab
  7. confirm, that:
    • no record for user status change email was created
    • email was sent to user's email address
  8. go to {Logs & Reports > System Log} section
  9. confirm, that no new records about deprecations were created

Part 3 (existing code, system setting = immediate, cron)

  1. login to Admin Console
  2. go to ConfigurationWebsiteAdvanced section
  3. set Email Delivery setting to Email Queue and save changes
  4. go to User ManagementUsers section
  5. press Approve or Decline toolbar button to invert user status
  6. go to ConfigurationWebsiteAdvanced section
  7. set Email Delivery setting to Immediate and save changes
  8. go to User ManagementMailings section and click on Email Queue tab
  9. confirm, that:
    • a record for user status change email was created
    • email wasn't sent yet to user's email address
  10. in CLI run php tools/cron.php command
  11. reload page
  12. confirm, that:
    • a record for user status change email was removed
    • email was sent to user's email address
  13. go to {Logs & Reports > System Log} section
  14. confirm, that no new records about deprecations were created

Part 4 (deprecated code, system setting = queue, ajax)

  1. in IDE:
    • open /core/admin_templates/mailing_lists/send_queue.tpl file for editing
    • replace email-queue_event="OnProcessAjax" with email-template_event="OnProcessEmailQueue"
    • replace pass="m,email-queue" with pass="m,email-template"
    • save changes
  2. login to Admin Console
  3. go to ConfigurationWebsiteAdvanced section
  4. set Email Delivery setting to Email Queue and save changes
  5. go to User ManagementUsers section
  6. press Approve or Decline toolbar button to invert user status
  7. go to User ManagementMailings section and click on Email Queue tab
  8. confirm, that:
    • a record for user status change email was created
    • email wasn't sent yet to user's email address
  9. press Process Queue toolbar button
  10. confirm, that:
    • a record for user status change email was removed
    • email was sent to user's email address
  11. go to {Logs & Reports > System Log} section
  12. confirm, that new record about deprecation was created
  13. rollback changes made to /core/admin_templates/mailing_lists/send_queue.tpl file

Part 5 (deprecated code, system setting = immediate, cron)

  1. login to Admin Console
  2. go to ConfigurationWebsiteScheduled Tasks section
  3. disable scheduled task with email-queue:OnProcess event
  4. create new scheduled task with these settings:
    • name: process_email_queue2
    • event: mailing-list:OnProcessEmailQueue
  5. go to ConfigurationWebsiteAdvanced section
  6. set Email Delivery setting to Email Queue and save changes
  7. go to User ManagementUsers section
  8. press Approve or Decline toolbar button to invert user status
  9. go to ConfigurationWebsiteAdvanced section
  10. set Email Delivery setting to Immediate and save changes
  11. go to User ManagementMailings section and click on Email Queue tab
  12. confirm, that:
    • a record for user status change email was created
    • email wasn't sent yet to user's email address
  13. in CLI run php tools/cron.php command
  14. reload page
  15. confirm, that:
    • a record for user status change email was removed
    • email was sent to user's email address
  16. go to {Logs & Reports > System Log} section
  17. confirm, that no new records about deprecations were created (in future if we implement http://community.in-portal.org/x/WIFYAQ they might be created)
  18. delete scheduled task with mailing-list:OnProcessEmailQueue event
  19. enable scheduled task with email-queue:OnProcess event

Part 6 (the "$immediate_send" param usage)

  1. in IDE:
    • open \kApplication::_email method for editing
    • in the call to \kEmail::send specify true for $immediate_send argument
    • save changes
  2. login to Admin Console
  3. go to ConfigurationWebsiteAdvanced section
  4. set Email Delivery setting to Email Queue and save changes
  5. go to User ManagementUsers section
  6. press Approve or Decline toolbar button to invert user status
  7. go to User ManagementMailings section and click on Email Queue tab
  8. confirm, that:
    • no record for user status change email was created
    • email was sent to user's email address
  9. go to {Logs & Reports > System Log} section
  10. confirm, that no new records about deprecations were created
  11. in IDE: revert changes to \kApplication::_email method

Part 7 (the "processQueue" messages override)

$messages = $mailing_list_helper->getMessages();

if ( count($messages) > 0 ) {
	array_pop($messages);
}

$message_count = $mailing_list_helper->processQueue($messages);
  1. in IDE:
    • open \EmailQueueEventHandler::OnProcessAjax method for editing
    • change $message_count = $mailing_list_helper->processQueue(); line into code snipper shown above
    • save changes
  2. login to Admin Console
  3. go to ConfigurationWebsiteAdvanced section
  4. set Email Delivery setting to Email Queue and save changes
  5. go to User ManagementUsers section
  6. press Approve or Decline toolbar button to invert user status (first time)
  7. press Approve or Decline toolbar button to invert user status (second time)
  8. go to User ManagementMailings section and click on Email Queue tab
  9. confirm, that:
    • two records for user status change email were created
    • emails weren't sent yet to user's email address
  10. press Process Queue toolbar button
  11. confirm, that:
    • one record for user status change email was removed
    • one email was sent to user's email address
  12. go to {Logs & Reports > System Log} section
  13. confirm, that new record about deprecation was created
  14. rollback changes to the \EmailQueueEventHandler::OnProcessAjax method

Part 8 (the "_ensureDefault" method)

/** @var MailingListHelper $mailing_list_helper */
$mailing_list_helper = $this->Application->recallObject('MailingListHelper');

$a = $this->_ensureDefault('MailingListSendPerStep');
$b = $mailing_list_helper->getSetting('MailingListSendPerStep');
die(var_dump($a === $b));
  1. in IDE:
    • open \MailingListEventHandler::OnPreCreate method for editing
    • add code from snippet above to it
  2. login to Admin Console
  3. go to User ManagementMailings section
  4. press Add button on toolbar
  5. confirm, that:
    • popup/modal window was opened
    • it has true word in it
  6. in IDE: rollback changes to \MailingListEventHandler::OnPreCreate method

Diff Detail

Repository
rINP In-Portal
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

alex created this revision.Jul 3 2017, 5:07 AM
alex edited the test plan for this revision. (Show Details)Jul 3 2017, 5:07 AM
alex edited the test plan for this revision. (Show Details)
erik requested changes to this revision.Jul 5 2017, 6:03 AM

All tests passed, excepting creating records about deprecated calls in the System Log - on tests such records never created. System Log is empty.

This revision now requires changes to proceed.Jul 5 2017, 6:03 AM
alex requested review of this revision.Jul 5 2017, 6:12 AM
alex edited edge metadata.

After speaking with @erik it turned out, that System Log was disabled on his In-Portal install. So need to retest all over again.

erik requested changes to this revision.Jul 7 2017, 6:16 AM

Tested with system log enabled. No deprecation warnings found. All system log messages, got when testing, displayed on screenshot -

This revision now requires changes to proceed.Jul 7 2017, 6:16 AM
alex requested review of this revision.Jul 7 2017, 9:14 AM
alex edited the test plan for this revision. (Show Details)
alex edited edge metadata.

The deprecation notices are triggered only in Debug Mode. After talking with @erik over Skype we've found out that debug mode was disabled via debug_off cookie. Please review again.

erik accepted this revision.Jul 11 2017, 4:14 AM
This revision is now accepted and ready to land.Jul 11 2017, 4:14 AM
This revision was automatically updated to reflect the committed changes.