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 #5333

Only variables should be returned by reference; triggers notices since php 4.4.0

Details

Submitted2005-09-08 11:38 UTC
Frommatl-pear at jijenik dot com
Assignedcipri
StatusClosed
PackageMail_Mime
PHP Version4.4.0
OSXP
Roadmaps1.4.0, 1.4.0a1

Comments

[2005-09-08 11:38 UTC] matl-pear at jijenik dot com

Description:
------------
Since upgrading to php 4.4.0, the mime.php script triggers some notices:

Notice: Only variable references should be returned by reference in ...path...\mime.php on line 341

Notice: Only variable references should be returned by reference in ...path...\mime.php on line 593

I have display_errors = On set in php.ini

This is the revision string of the mimi.php file

// $Id: mime.php,v 1.39 2005/06/13 21:24:16 cipri Exp $

Test script:
---------------
simply including the mail.php should trigger the notices being displayed.

[2005-09-08 17:40 UTC] florent at creative-area dot net

same problem with php 4.4.0 on Linux :

Notice: Only variable references should be returned by reference in /wwwroot/php/lib/php/Mail/mime.php on line 375

Notice: Only variable references should be returned by reference in /wwwroot/php/lib/php/Mail/mime.php on line 416

Notice: Only variable references should be returned by reference in /wwwroot/php/lib/php/Mail/mime.php on line 416

Notice: Only variable references should be returned by reference in /wwwroot/php/lib/php/Mail/mime.php on line 593

[2005-09-09 06:54 UTC] matl-pear at jijenik dot com

I found some more info and a (kludgy) workaround for this issue.

Each of the four problematic lines contains a statement in the form "return new SomeClass()". For some reason you cannot return a pointer to a newly created instance since PHP 4.4.0 (there is some documentation on that in the PHP release notes).

the kludy workaround: replace the "return new SomeClass()" statement by these two lines:

$newObj =& new SomeClass();
return $newObj;

Wel, what can I say? PHP is a messy language :)

[2005-12-07 19:17 UTC] phyre at rogers dot com

Still remains unfixed for three months? We're into PHP5.1 these days, so these warnings really shouldn't be occuring as the error reporting and strict standards continues to increase. This and other errors in particular with E_STRICT on.

[2006-02-20 11:36 UTC] winkler at multimedia dot cz

'the fix' still does not eliminate all the notices, the return statement in Mail_mime::headers() on line 598 of mime.php for instance.

[2006-02-22 13:04 UTC] j dot svoboda at phoenix dot cz

Version 1.41 still gives errors on line 444.
PHP Notice: Only variable references should be returned by reference in /usr/local/lib/php/Mail/mime.php on line 444

[2006-02-28 18:21 UTC] vasilyev at cliffgear dot com

Current (v 1.41 2006/02/20) version of mime.php still has some problems with returning by reference:

*function &_addHtmlImagePart(&$obj, $value) and function &_addAttachmentPart(&$obj, $value):
these function do not return a value, which is a problem since you can't return NULL by reference.

*function &get($build_params = null) can return false constant value, which is also a problem

[2006-03-20 13:24 UTC] j dot svoboda at phoenix dot cz

Function &_addAttachmentPart(&$obj, $value) still does not return value. (v 1.42 2006/03/14)

[2006-04-01 22:18 UTC] busby at edoceo dot com

I'm using PHP 5 and tried the latest CVS versions of Mail_Mime and Mail packages, there were notices/warnings about using public/private and still some 'return by reference' issues. I hacked up a few of the files to get it to work for me, not a highly professional fix, just quick and dirty. Patches here:

http://www.edoceo.com/busby/patches/pearmail.php

(I didn't know if it's cool to push in big diffs so I just linked it)

[2006-06-08 15:55 UTC] alan dot harder at sun dot com

When will a stable release include the return by reference fixes?

[2006-07-17 12:04 UTC] koto at webworkers dot pl

Is there any progress in releasing the next version of the package with CVS patches?

[2006-12-20 17:22 UTC] davhana at hotmail dot com

Its neary 2007 and the problem still exists..... Is this problem going to be fixed or is this package dead? Will someone please update the status of this package.

[2007-01-13 14:23 UTC] rob at someplace dot com

This problem isn't solved yet:
If I try to use the mail_queue package (on PHP 5.2) the following two notices still appear:

Notice: Only variable references should be returned by reference in C:\Program Files\PHP\PEAR\Mail\mime.php on line 320

Notice: Only variable references should be returned by reference in C:\Program Files\PHP\PEAR\Mail\mime.php on line 593

[2007-02-13 21:17 UTC] adul at shadow-lands dot net

I used the below work around to get it working for me. I am going to move away from mail mime as I have found a better package to use.

For those of you still having issues try out swiftmailer.

http://www.swiftmailer.org

"I found some more info and a (kludgy) workaround for this issue.

Each of the four problematic lines contains a statement in the form
"return new SomeClass()". For some reason you cannot return a
pointer to a newly created instance since PHP 4.4.0 (there is some
documentation on that in the PHP release notes).

the kludy workaround: replace the "return new SomeClass()"
statement by these two lines:

$newObj =& new SomeClass();
return $newObj;

Wel, what can I say? PHP is a messy language :)"