Depending on how often I set up the report to be sent I will receive a completely blank email. If I disable this module I simply stop receiving the email.

Has anyone else experienced this problem or is there a good way to troubleshoot it?

Comments

liquidcms’s picture

hmm.. had thought i fixed that issue ages ago. perhaps it is fixed in dev release which i just added to project page (might take a few hours to show a download available). I also applied a patch submitted by another user; which i doubt impacts your issue.. but please try with the dev release and let me know. thanks.

NROTC_Webmaster’s picture

I didn't know there was a dev version available. It isn't showing up under the module.

liquidcms’s picture

it should be there now

NROTC_Webmaster’s picture

The one you uploaded crashes the site. It looks like it is for drupal 5???

liquidcms’s picture

hmm.. Git issues perhaps.. i'll take a look tonight

liquidcms’s picture

-dev should be fixed now.

NROTC_Webmaster’s picture

Version: 6.x-1.3 » 6.x-1.x-dev

I get the following error when I try to install the dev version.
Fatal error: Only variables can be passed by reference in /public_html/sites/all/modules/php_errors/php_errors.module on line 208

I did however successfully install the 1.5 version and now when I go to the archive it actually has a date there. I cannot open it but I'm hoping that I will start receiving the reports.

Is there a way to force it to send instantly or do I just need to wait for the daily to send it to me?

Thanks for your help in this.

liquidcms’s picture

yes, dev is still not the right version.. GiT is killing me.. lol

i think what is there for 1.5 is current - no, there is no way to do a force send; let me know if something doesn't work.

thanks.

NROTC_Webmaster’s picture

I'm still getting the blank email.

NROTC_Webmaster’s picture

In an effort to debug this I added an on demand and hourly function to assist instead of waiting an entire day between emails. I know this doesn't really have any other useful functionality but figured it might help someone else.

For the on demand function I also had to add that ability to the CronPlus so make sure you do that if you want to use it.
http://drupal.org/node/363809#comment-4709716

@ Line 90       
  $form['php_errors_notify_frequency'] = array(
    '#type' => 'radios',   
    '#title' => t('Frequency of Notification'),
--    '#options' => array(0 => 'never', 1 => 'daily', 2 => 'weekly', 3 => 'monthly'),
++    '#options' => array(0 => 'never', 1 => 'on demand', 2 => 'hourly', 3 => 'daily', 4 => 'weekly', 5 => 'monthly'),
    '#default_value' => variable_get('php_errors_notify_frequency', 2),
    '#description' => t("Select how often email error reports will be sent. NOTE: archiving is done weekly, regardless of this setting."),
  ); 

@ Line 206
/* Uses CronPLUS module to do a couple weekly tasks:
*     - send email notifications to selected users (frequency based on frequency setting)
*     - archive the error report (weekly)
*/
++function php_errors_cronplus_on_demand($now, $last_cron, $last_this) {
++  if (variable_get('php_errors_notify_frequency', 0) == 1) _php_errors_send_notifications();
++}
++function php_errors_cronplus_hourly($now, $last_cron, $last_this) {
++  if (variable_get('php_errors_notify_frequency', 0) == 2) _php_errors_send_notifications();
++}
function php_errors_cronplus_daily($now, $last_cron, $last_this) {
--  if (variable_get('php_errors_notify_frequency', 0) == 2) _php_errors_send_notifications();
++  if (variable_get('php_errors_notify_frequency', 0) == 3) _php_errors_send_notifications();
}
function php_errors_cronplus_weekly($now, $last_cron, $last_this) {
--  if (variable_get('php_errors_notify_frequency', 2) == 2) _php_errors_send_notifications();    // default to weekly if not set
++  if (variable_get('php_errors_notify_frequency', 4) == 4) _php_errors_send_notifications();    // default to weekly if not set
  
  // archive the report
  $report = _php_errors_show();
  db_query("INSERT INTO {php_errors_archive} (report, created) VALUES ('%s', %d)", $report, time()); 
}   
function php_errors_cronplus_monthly($now, $last_cron, $last_this) {
--  if (variable_get('php_errors_notify_frequency', 0) == 3) _php_errors_send_notifications();
++  if (variable_get('php_errors_notify_frequency', 0) == 5) _php_errors_send_notifications();
}

The email it's sending is with only first portion of the email address listed in the Admin Notification Email Addresses form.
Such as email@ (hotmail.com email@hotmail.com)
I don't know if this is somehow interfering with the rest of the email but I figured it was a start.

NROTC_Webmaster’s picture

When I use the following code in mail.inc around line 130 I get all of the info but but the subject and body within $message are blank

  drupal_set_message(dprint_r('Start', 1)); 
  drupal_set_message(dprint_r('$message = ', 2)); 
  drupal_set_message(dprint_r($message, 3)); 
  drupal_set_message(dprint_r('$params = ', 4)); 
  drupal_set_message(dprint_r($params, 5)); 
  drupal_set_message(dprint_r('Finish', 6)); 

Which produces

Start
$message = 
Array
(
    [id] => php_errors_php_error_report
    [to] => email@example.com <email@example.com>
    [from] => email@example.net
    [language] => 
    [params] => Array
        (
            [from] => Site data <email@example.net>
            [subject] => PHP Error Summary Report
            [body] => The following is this weeks PHP Error Summary Report.

Regards,

Site data

Count      Date                 Location                                                
Error
--------------------------------------------------------------------------------

381        07-08-2011           http://example.net/admin/settings/cronplus/run          
%message in %file on line %line.

412        07-08-2011           http://example.net/admin/settings/cronplus/run          
%error: %message in %function (line %line of %file).


        )

    [subject] => 
    [body] => 
    [headers] => Array
        (
            [MIME-Version] => 1.0
            [Content-Type] => text/plain; charset=UTF-8; format=flowed; delsp=yes
            [Content-Transfer-Encoding] => 8Bit
            [X-Mailer] => Drupal
            [Errors-To] => email@example.net
            [Return-Path] => email@example.net
            [Sender] => email@example.net
            [From] => email@example.net
        )

    [result] => 1
)
$params = 
Array
(
    [from] => Site data <email@example.net>
    [subject] => PHP Error Summary Report
    [body] => The following is this weeks PHP Error Summary Report.

Regards,

Site data

Count      Date                 Location                                                
Error
--------------------------------------------------------------------------------

381        07-08-2011           http://example.net/admin/settings/cronplus/run          
%message in %file on line %line.

412        07-08-2011           http://example.net/admin/settings/cronplus/run          
%error: %message in %function (line %line of %file).


)
Finish
NROTC_Webmaster’s picture

okay so I was able to make it work by altering lines 92 & 93 in mail.inc but I don't think this is the way it should be done.

I simply changed

function drupal_mail($module, $key, $to, $language, $params = array(), $from = NULL, $send = TRUE) {
  $default_from = variable_get('site_mail', ini_get('sendmail_from'));

  // Bundle up the variables into a structured array for altering.
  $message = array(
    'id'       => $module .'_'. $key,
    'to'       => $to,
    'from'     => isset($from) ? $from : $default_from,
    'language' => $language,
    'params'   => $params,
--    'subject'  => '',
--    'body'     => array()
++    'subject'  => $params['subject'],
++    'body'     => $params['body']
  );

and although not essential I changed lines 227 and 254 in php_errors.module

@@227
--  $params['from'] = "$site_name <". variable_get('site_mail', ini_get('sendmail_from')) .'>';;
++  $from = "$site_name <". variable_get('site_mail', ini_get('sendmail_from')) .'>';;

@@254
--  if (drupal_mail('php_errors', 'php_error_report', $recipients, language_default(), $params)) {
++  if (drupal_mail('php_errors', 'php_error_report', $recipients, language_default(), $params, $from)) {
    watchdog('action', 'Sent email to %recipients', array('%recipients' => $recipients));
  }

Please let me know if you know of any other way to pass the parameters to drupal_mail correctly.

NROTC_Webmaster’s picture

StatusFileSize
new2.32 KB

I finally figured out the problem. It seems at some point they changed how parameters are passed to the mail function. To pull the parameters drupal is looking for a specific function when building the message. That data is stored in in the first part of the message as in 'php_errors' and then it adds the _mail. To fix the issue I simply created a php_errors_mail function and passed the message subject and body in there..

The patch is attached.

NROTC_Webmaster’s picture

Status: Active » Needs review

Sorry I forgot to change the status