PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Mail » Mail_Mime » Bug #9956

Notices being thrown

Details

Submitted2007-01-27 03:32 UTC
Fromlturmelle at guamcell dot com
Assignedcipri
StatusClosed
PackageMail_Mime
PHP Version5.1.4
OSxp sp2
Roadmaps1.4.0, 1.4.0a1

Comments

[2007-01-27 03:32 UTC] lturmelle at guamcell dot com

Description:
------------
Various places in the class are now throwing E_NOTICE for returning executed code instead of a variable. This is with E_STRICT turned off in this PHP version.

Have also had the error thrown on lines 356 and 434 - though not on the provided test script.

Test script:
---------------
<?php
error_reporting(E_ALL);
require 'Mail.php';
require 'Mail/mime.php';

$mime = new Mail_mime("\r\n");
$mime->setTXTBody('Howdy');
$body = $mime->get();
$hdrs = $mime->headers(array(
'From' => 'lig@mydomain.com',
'Subject' => 'Howdy'
)
);
$mail = Mail::factory('smtp', array('host'=>'smtp.myisp.net'));
echo ($mail->send('lig@anotherdomain.com', $hdrs, $body)) ? 'TRUE' : 'FALSE';
?>

Expected result:
----------------
TRUE

Actual result:
--------------
<br />
<b>Notice</b>: Only variable references should be returned by reference in <b>C:\php\PEAR\Mail\mime.php</b> on line <b>320</b><br />
<br />
<b>Notice</b>: Only variable references should be returned by reference in <b>C:\php\PEAR\Mail\mime.php</b> on line <b>593</b><br />
TRUE

[2007-01-29 10:37 UTC] lturmelle at guamcell dot com

I haven't used PHP4 OO in a long time and these are a bit ugly - but they seem to work for me. Here is a few patches for this report :

mime.php
Line 356
- return new Mail_mimePart('', $params);
+ $var = &new Mail_mimePart('', $params);
+ return $var;

mime.php
Line 320
- return new Mail_mimePart($text, $params);
+ $var = &new Mail_mimePart($text, $params);
+ return $var;

mime.php
Line 593
- $this->_headers = array_merge($headers, $this->_headers);
- return $this->_encodeHeaders($this->_headers);
+ $var = array_merge($headers, $this->_headers);
+ $this->_headers = $var;
+ $var2 = &$this->_encodeHeaders($this->_headers);
+ return $var2;

[2007-01-30 16:38 UTC] m at mattanjakern dot de

Same problem here... Is this package maintained no longer?
Full diff for that problem should be the following.

--- mime.php.old 2007-01-30 19:11:22.000000000 +0100
+++ mime.php 2007-01-30 19:14:14.000000000 +0100
@@ -317,7 +317,8 @@
if (is_object($obj)) {
return $obj->addSubpart($text, $params);
} else {
- return new Mail_mimePart($text, $params);
+ $tmp = &new Mail_mimePart($text, $params);
+ return $tmp;
}
}

@@ -338,7 +339,8 @@
if (is_object($obj)) {
return $obj->addSubpart($this->_htmlbody, $params);
} else {
- return new Mail_mimePart($this->_htmlbody, $params);
+ $tmp = &new Mail_mimePart($this->_htmlbody, $params);
+ return $tmp;
}
}

@@ -353,7 +355,8 @@
function &_addMixedPart()
{
$params['content_type'] = 'multipart/mixed';
- return new Mail_mimePart('', $params);
+ $tmp = &new Mail_mimePart('', $params);
+ return $tmp;
}

/**
@@ -372,7 +375,8 @@
if (is_object($obj)) {
return $obj->addSubpart('', $params);
} else {
- return new Mail_mimePart('', $params);
+ $tmp = &new Mail_mimePart('', $params);
+ return $tmp;
}
}

@@ -392,7 +396,8 @@
if (is_object($obj)) {
return $obj->addSubpart('', $params);
} else {
- return new Mail_mimePart('', $params);
+ $tmp = &new Mail_mimePart('', $params);
+ return $tmp;
}
}

@@ -590,7 +595,9 @@
}
$this->_headers = array_merge($headers, $this->_headers);

- return $this->_encodeHeaders($this->_headers);
+ $tmp = $this->_encodeHeaders($this->_headers);
+ $tmp_p = &$tmp;
+ return $tmp_p;
}

/**

[2007-02-14 13:00 UTC] bretrzaun at hotmail dot com

Same problem here - would like to get an new release instead of patching the file.

Is anyone listening ?