Zend Framework

Override maximum_log in Zend_Mail_Protocol_Abstract

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.10.4
  • Fix Version/s: 1.11.0
  • Component/s: Zend_Mail
  • Labels:
    None

Description

In my app, I want to log the whole SMTP transaction. To do so, I'm using:

$tr->getConnection()->getLog()

{/quote}

This works and provides me with the SMTP transaction, however.. its length is limited.
Upon further investigation there is an hard coded value MAXIMUM_LOG in Zend_Mail_Protocol_Abstract.

I've (temporarily) modified this from 64 to 4096 so it covers the whole transaction.In my app I remove everything between DATA and the
trailing .

Can there be a setter (and getter) to modify this limit?

Activity

Hide
Frank added a comment -

Maybe its also possible to add an option to disable the limit/checking of the limit.
Setting it to 999999 isn't very pretty.

Show
Frank added a comment - Maybe its also possible to add an option to disable the limit/checking of the limit. Setting it to 999999 isn't very pretty.
Hide
Josh Boyd added a comment -

Patch attached.

Show
Josh Boyd added a comment - Patch attached.
Hide
Satoru Yoshida added a comment -

Sorry, I have been inactive since last April.

Show
Satoru Yoshida added a comment - Sorry, I have been inactive since last April.
Hide
Dolf Schimmel (Freeaqingme) added a comment -

I will review the patch this week and commit it if okay.

Show
Dolf Schimmel (Freeaqingme) added a comment - I will review the patch this week and commit it if okay.
Hide
Frank added a comment -

Dolf, I hope you haven't forgot about this?

Show
Frank added a comment - Dolf, I hope you haven't forgot about this?
Hide
Michael Kliewe added a comment -

I would also love to see a change here because I have the problem that I want to send a mail with attachments >100MB, and my php memory limit of 512 MB is exhausted, I think this log is one of the problems.
I would like to disable logging completly, setting MAXIMUM_LOG to 0 is not enough because the big DATA request would be logged anyway into $this->_log and fill up my memory.

Show
Michael Kliewe added a comment - I would also love to see a change here because I have the problem that I want to send a mail with attachments >100MB, and my php memory limit of 512 MB is exhausted, I think this log is one of the problems. I would like to disable logging completly, setting MAXIMUM_LOG to 0 is not enough because the big DATA request would be logged anyway into $this->_log and fill up my memory.
Hide
Michael Kliewe added a comment -

Forget the sentence with the big DATA request, I have seen that there are thousands of little log entries instead of one big log entry when sending a big mail.

But I would like to disable this log per default because 99% of the users don't need it, it only wastes CPU. If a developer needs the log he can enable it then, but default should be off. Or default of $_maximumLog should be -1 which disable the log. In _addLog there has to be one line

if ($this->_maximumLog < 0) return;
Show
Michael Kliewe added a comment - Forget the sentence with the big DATA request, I have seen that there are thousands of little log entries instead of one big log entry when sending a big mail. But I would like to disable this log per default because 99% of the users don't need it, it only wastes CPU. If a developer needs the log he can enable it then, but default should be off. Or default of $_maximumLog should be -1 which disable the log. In _addLog there has to be one line
if ($this->_maximumLog < 0) return;
Hide
Dolf Schimmel (Freeaqingme) added a comment -

Resolved on trunk and will be released in the next major release.

Please beware that I'm unsure why originally it was chosen to use a constant for this. If it turns out there was a proper reason for that that's still legit this patch will be reverted.

In any case; thank you for reporting this issues and my apologies for the delays in fixing it.

Show
Dolf Schimmel (Freeaqingme) added a comment - Resolved on trunk and will be released in the next major release. Please beware that I'm unsure why originally it was chosen to use a constant for this. If it turns out there was a proper reason for that that's still legit this patch will be reverted. In any case; thank you for reporting this issues and my apologies for the delays in fixing it.
Hide
Josh Boyd added a comment -

Your commit is wrong, getMaximumLog is incorrectly named setMaximumLog.

Show
Josh Boyd added a comment - Your commit is wrong, getMaximumLog is incorrectly named setMaximumLog.
Hide
Dolf Schimmel (Freeaqingme) added a comment -

Should be fixed once again. Thanks.

Show
Dolf Schimmel (Freeaqingme) added a comment - Should be fixed once again. Thanks.
Hide
Michael Kliewe added a comment -

I checked your commit, Dolf, and I cannot see a possibility to disable the log. Should I create a new issue for that?

Because I don't want to log the transaction in production environment, and logging every line is a performance problem, because in my tests when sending a 60MB mail I have 300.000 calls of _addLog and also 300.000 calls of

$this->_log[] = $value;

Best solution would be to have something like

// Save request to internal log
if (true == $this->_loggingEnabled) {
    $this->_addLog($request . self::EOL);
}

in both _send() and _receive() so we don't have thousands of function calls.

Perhaps in ZF 2.0 we could even disable this logging feature by default because only developers need it for debugging, 99% of the users don't need that logging feature in a default installation. This would increase the performance of the component. But this would be a BC.

Show
Michael Kliewe added a comment - I checked your commit, Dolf, and I cannot see a possibility to disable the log. Should I create a new issue for that? Because I don't want to log the transaction in production environment, and logging every line is a performance problem, because in my tests when sending a 60MB mail I have 300.000 calls of _addLog and also 300.000 calls of
$this->_log[] = $value;
Best solution would be to have something like
// Save request to internal log
if (true == $this->_loggingEnabled) {
    $this->_addLog($request . self::EOL);
}
in both _send() and _receive() so we don't have thousands of function calls. Perhaps in ZF 2.0 we could even disable this logging feature by default because only developers need it for debugging, 99% of the users don't need that logging feature in a default installation. This would increase the performance of the component. But this would be a BC.
Hide
Josh Boyd added a comment -

Just call setMaximumLog(0) and logging is disabled.

Show
Josh Boyd added a comment - Just call setMaximumLog(0) and logging is disabled.
Hide
Michael Kliewe added a comment -

@Josh: I don't see it, could you please tell me the line? There is no "return" or something in _addLog(), so the function _addLog() is called every time and an entry is filled into the array $this->_log . You are right that this entry is shifted out on the next call of _addLog(), but it keeps filling the array 300.000 times.

Show
Michael Kliewe added a comment - @Josh: I don't see it, could you please tell me the line? There is no "return" or something in _addLog(), so the function _addLog() is called every time and an entry is filled into the array $this->_log . You are right that this entry is shifted out on the next call of _addLog(), but it keeps filling the array 300.000 times.

People

Vote (3)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: