8 / 8
Jul 2020

Hello Together,
and especially @RalfBecker :wink:

I have the following problem:
We have a custom infolog version. When pressing save/apply with “skip notifications” unchecked the saving process takes a very long time (about 20 seconds). Without notifications it takes about 1 second.
I saw that Swoolepush was implemented into the upcoming EGroupware Version 20.1. I am wondering if there is a simple way to change my infolog code, so that the notifications are updated asynchronously and do not delay the saving process?

Thank you for any input and
BR
Alex

  • created

    Jul '20
  • last reply

    Jul '20
  • 7

    replies

  • 1.6k

    views

  • 2

    users

  • 2

    links

I just opened an hour ago a ticket about notifications and calendar, same issue here, you can move the tracking calls doing the notification into an own method and call Api\Egw::on_shutdown() with that method and it’s parameters instead. Then the notification runs after sending the content to the user.

Next step is then to report notification errors via Api\Json\Push calls back to the user, which works from inside a on_shutdown function.

Ralf

Hallo Ralf,
thank very much!
I think the first part is clear to me. Instead of doing native notifications I will call Api\Egw::on_shutdown() with a correct callback function and all needed parameters.
But I am not sure if understood the second part correctly:
Should I use Api\Json\Push from inside the above mentioned callback function? Which “on_shutdown” function could I use?
Thanks again!
Alex

Hi Alex,

if inside the on_shutdown callback you need to respond to the user, eg. because you run into an error, you can no longer use regular

Api\Json\Response::get()->message($error_msg, 'error');

because the response is already send to the user.

Instead you have to use

(new Api\Json\Push())->message($error_msg, 'error');

Ralf

Hi Alex,

sending mail in on_shutdown method fails with Horde SMTP, when it tries to construct the mail and uses stream-filters for that :frowning:

PHP Warning: stream_filter_remove(): Unable to flush filter, not removing in /var/www/egroupware/vendor/pear-pear.horde.org/Horde_Smtp/Horde/Smtp.php on line 557
#1 /var/www/egroupware/vendor/pear-pear.horde.org/Horde_Smtp/Horde/Smtp.php(557): stream_filter_remove(Resource id #98)
#2 /var/www/egroupware/vendor/pear-pear.horde.org/Horde_Mail/Horde/Mail/Transport/Smtphorde.php(143): Horde_Smtp->send(Object(Horde_Mail_Rfc822_Address), Object(Horde_Mail_Rfc822_List), Resource id #92)
#3 /var/www/egroupware/vendor/pear-pear.horde.org/Horde_Mime/Horde/Mime/Part.php(1620): Horde_Mail_Transport_Smtphorde->send('Miss Sysop BB-t...', Array, Resource id #84)
#4 /var/www/egroupware/api/src/Mailer.php(747): Horde_Mime_Part->send('Miss Sysop BB-t...', Object(Horde_Mime_Headers), Object(Horde_Mail_Transport_Smtphorde), Array)
#5 /var/www/egroupware/api/src/Mailer.php(602): EGroupware\Api\Mailer->_send(Object(Horde_Mail_Transport_Smtphorde), true, false, Array)
#6 /var/www/egroupware/notifications/inc/class.notifications_email.inc.php(139): EGroupware\Api\Mailer->send()
#7 /var/www/egroupware/notifications/inc/class.notifications.inc.php(572): notifications_email->send(Array, 'Notify Test', Array, Array, Array)
#8 /var/www/egroupware/calendar/inc/class.calendar_boupdate.inc.php(1200): notifications->send()
#9 /var/www/egroupware/calendar/inc/class.calendar_boupdate.inc.php(828): calendar_boupdate->_send_update(1, Array, Array, Array, 5, NULL)
#10 [internal function]: calendar_boupdate::{closure}(Object(calendar_boupdate), 1, Array, Array, Array, 0, NULL)
#11 /var/www/egroupware/api/src/Egw.php(606): call_user_func_array(Object(Closure), Array)
#12 [internal function]: EGroupware\Api\Egw->__destruct()
#13 {main}

Which leads to a complete empty mail as you can see in the SMTP log:

>> Fri, 17 Jul 2020 11:26:50 +0200
>> Connection to: smtp://smtp.egroupware.org:465
S: 220 mail.egroupware.org ESMTP Postfix
C: EHLO 30f7744c9fff
S: 250-mail.egroupware.org
S: 250-PIPELINING
S: 250-SIZE 65000000
S: 250-VRFY
S: 250-ETRN
S: 250-AUTH PLAIN LOGIN
S: 250-AUTH=PLAIN LOGIN
S: 250-ENHANCEDSTATUSCODES
S: 250-8BITMIME
S: 250-DSN
S: 250 CHUNKING
[AUTH Command - method: PLAIN; username: rb@egroupware.org]
S: 235 2.7.0 Authentication successful
C: MAIL FROM:<rb@egroupware.org> SIZE=0 BODY=7BIT
C: RCPT TO:<sysop@bb-trunk.egroupware.de>
S: 250 2.1.0 Ok
S: 250 2.1.5 Ok
C: DATA
S: 354 End data with <CR><LF>.<CR><LF>
C:
C: .
S: 250 2.0.0 Ok: queued as 52D4533

Looks like we triggering some PHP bug when trying to use stream-filters in a destructor.

While the whole stream-filter business is necessary for sending huge mails, our notification mails or meeting requests are quite small and would not require it. Unfortunately Horde SMTP does not allow to switch it off.

I let you know, if we found or decided on any alternative.

Ralf