Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPMailerAutoload.php: PHP Deprecated: __autoload() is deprecated, use spl_autoload_register() instead #569

Closed
q2apro opened this issue Dec 16, 2017 · 6 comments

Comments

@q2apro
Copy link

q2apro commented Dec 16, 2017

Getting this within my error logs:

PHP Deprecated: __autoload() is deprecated, use spl_autoload_register() instead in /qa-include/vendor/PHPMailer/PHPMailerAutoload.php on line 45

Should function __autoload($classname) be removed? Guess there is nearly noone using a version below PHP 5.1.2.

PS: There is already PHPMailer 6 available: https://github.com/PHPMailer/PHPMailer/releases

@svivian
Copy link
Collaborator

svivian commented Dec 16, 2017

Strange. That function is only added if the version is below 5.1.2 so you should never get that notice. Can you tell me the output of this PHP script on your system?

<?php
var_dump(PHP_VERSION);
var_dump(version_compare(PHP_VERSION, '5.1.2', '>='));

BTW we can't upgrade to PHPMailer 6 just yet since it requires PHP 5.5.

@q2apro
Copy link
Author

q2apro commented Dec 16, 2017

output of this PHP script on your system

What output? The PHPMailer caused the error message above. The emails went out, as far as I noticed. PHP is 7.2.

@svivian
Copy link
Collaborator

svivian commented Dec 16, 2017

I mean can you make a PHP script on your site with the code I posted above and let me know what you see? For example you should see something like:

string '7.1.7' (length=5)
boolean true

The only reason I can think of why you're getting that notice is because there is some problem with the version_compare function on your server.

@svivian
Copy link
Collaborator

svivian commented Dec 17, 2017

Managed to reproduce this on PHP 7.2. Strangely, for me the notice appears only the first page load, then it never appears again until I restart the server. Might be a bug in PHP itself.

Probably the easiest thing to do is just remove the autoload bit manually from our PHPMailer copy.

@q2apro
Copy link
Author

q2apro commented Dec 17, 2017

Exactly what I did, removing the autoload. Weird PHP behavior.

@q2apro q2apro closed this as completed Dec 17, 2017
@svivian
Copy link
Collaborator

svivian commented Dec 23, 2017

I checked with the PHP devs and this is apparently intended behaviour. The notice is generated during the code 'parsing' phase, regardless of whether that part of the code is executed.

Anyway, the PHPMailer autoloader doesn't do much - we only need 2 PHP files. So I've removed it and included the classes manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants