MantisBT: master 9c45e146

Author Committer Branch Timestamp Parent
dregad dregad master 2015-03-30 05:41 master ffeb73c8
Affected Issues  0017458: SOAP API does not send e-mails
 0017460: Email notifications are sent in batches
Changeset

Synchronous email sending via shutdown function

Mantis provides 2 ways of processing email: synchronously (default) or
using a cron job. Historically, the former was achieved by processing
the email queue immediately after each email-generating action.

This approach could lead to a severe performance degradation when the
queue contains a backlog of pending messages which can't be sent (e.g.
due to invalid email addresses or server problems).

In early 2014, an attempt was made to improve this for fastcgi by
processing the queue at the bottom of each displayed page (in html_end()
function), which introduced regressions for SOAP API (issue 0017458) as
well as plugins and other corner cases (issues 0017460).

This commit resolves the problem by registering a shutdown function to
process the email queue in core.php, which ensures that email gets sent
no matter what.

To avoid multiple executions of the shutdown function for a single user
request (which may lead to several executions of core.php, e.g. when
building dynamic css, javascript translations, etc), an arbitrary 5
seconds delay is observed between each register_shutdown_function()
call.

Fixes 0017460

mod - api/soap/mantisconnect.php Diff File
mod - core.php Diff File
mod - core/email_api.php Diff File
mod - core/html_api.php Diff File