Undefined index: _SWIFT_LOG

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
georgeoc
Forum Contributor
Posts: 166
Joined: Wed Aug 09, 2006 4:21 pm
Location: London, UK

Undefined index: _SWIFT_LOG

Post by georgeoc »

Hi all,

Chris - thanks for your work on Swift. I've just started experimenting with it for my application and I'm loving it so far!

One small error when I send an email with SMTP:

Code: Select all

Undefined index: _SWIFT_LOG [includes/swift/Swift/LogContainer.php, line 42]
Looking at the code, I can't understand why $GLOBALS["_SWIFT_LOG"] is not defined, as you give it a value of null at the top of the page. I have a feeling it might be something to do with php.ini configuration, as I only get the error on my test server, and not my development server. All errors are enabled on both.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Very odd. Unless you have some whacky code somewhere before Swift gets used which empties the $GLOBALS array I can't see why you'd get that. I doubt you can turn the $GLOBALS array off neither :?

Not sure what else to suggest other than changing the code to use the "global" keyword rather than the $GLOBALS array.
bronwen
Forum Newbie
Posts: 1
Joined: Sat Apr 05, 2008 7:51 am

Re: Undefined index: _SWIFT_LOG

Post by bronwen »

I had the same error message and found it occurred because I was running the php4 version of Swift Mail under php5.

The Swift_Connection_SMTP class has a __destruct() method (which wouldn't normally be called under php 4). The destructor calls stop() which logs the closure, and we then have an error message about an undefined global in logContainer because by now all the globals have been destroyed.

Just in case anyone else has the same problem.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Undefined index: _SWIFT_LOG

Post by Chris Corbyn »

bronwen wrote:I had the same error message and found it occurred because I was running the php4 version of Swift Mail under php5.

The Swift_Connection_SMTP class has a __destruct() method (which wouldn't normally be called under php 4). The destructor calls stop() which logs the closure, and we then have an error message about an undefined global in logContainer because by now all the globals have been destroyed.

Just in case anyone else has the same problem.
Well spotted, and thanks for sharing :) This will indeed be the problem due to the timing at which __destruct() runs.

/me waves goodbye to PHP4 support
georgeoc
Forum Contributor
Posts: 166
Joined: Wed Aug 09, 2006 4:21 pm
Location: London, UK

Re: Undefined index: _SWIFT_LOG

Post by georgeoc »

Chris Corbyn wrote:/me waves goodbye to PHP4 support
Me too, thankfully!
Post Reply