? Success

User tests: Successful: Unsuccessful:

avatar OctavianC
OctavianC
12 Aug 2016

Summary of Changes

I've set $result as false by default in the addAttachment() method.

Testing Instructions

JFactory::getMailer()->addAttachment(array()); will show a PHP Notice:

Notice: Undefined variable: result in /libraries/joomla/mail/mail.php on line 479

I've bumped my head against a wall for so long until I figured this out; $result never gets initialized because the array has 0 elements and this part won't run:

foreach ($path as $key => $file)
{
    if (!empty($name))
    {
        $result = parent::addAttachment($file, $name[$key], $encoding, $type);
    }
    else
    {
        $result = parent::addAttachment($file, $name, $encoding, $type);
    }
}

So we'll end up with an unset $result here:

if ($result === false)

Documentation Changes Required

None

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
3.00

avatar joomla-cms-bot joomla-cms-bot - change - 12 Aug 2016
Category Libraries
avatar OctavianC OctavianC - open - 12 Aug 2016
avatar OctavianC OctavianC - change - 12 Aug 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 12 Aug 2016
Labels Added: ?
avatar berserk41
berserk41 - comment - 27 Sep 2016

I ran into this same error. On line 479 it is checking if ($results === false), but $results is undefined. Not sure why this is in there, but I commented out the whole if statement and I no longer get the error. I'm sure it serves a purpose, but until it is fixed this is my working solution. There are 2 other places in mail.php that this same code occurs FYI.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11568.

avatar zero-24
zero-24 - comment - 8 Oct 2016

This is fixed in staging by #11764. Thanks

avatar zero-24 zero-24 - change - 8 Oct 2016
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2016-10-08 14:13:19
Closed_By zero-24
avatar zero-24 zero-24 - close - 8 Oct 2016

Add a Comment

Login with GitHub to post a comment