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

PHP 7.2: "__autoload() is deprecated, use spl_autoload_register() instead" #154

Closed
zerocrates opened this issue Dec 19, 2017 · 9 comments
Closed

Comments

@zerocrates
Copy link
Contributor

The mere presence of the __autoload function definition, even inside the conditional, seems to raise this warning on PHP 7.2. It's just a deprecation warning but it will crop up and cause problems for people running tests and things like that (where I saw it).

Simply eliminating the __autoload fallback from HTMLPurifier.autoload.php
would quiet the complaint. As it's only support for ancient versions it might be prudent to do so.

Otherwise, I suppose you could split off the __autoload definition into a separate file that would only be conditionally include'd, thus making it so the problematic definition isn't visible when it's not needed.

@ezyang
Copy link
Owner

ezyang commented Dec 23, 2017

OK! I'll take a patch that does this.

@zerocrates
Copy link
Contributor Author

which? dropping the fallback or separating it out?

@ezyang
Copy link
Owner

ezyang commented Dec 27, 2017

Separating it out please!

@3alampro
Copy link

3alampro commented Jan 3, 2018

@ezyang kindly can we have release for this so we can update our project with composer update

@ezyang
Copy link
Owner

ezyang commented Jan 8, 2018

OK, one of these days :)

@brandonfarber
Copy link

Anything we can do to help speed up getting a new build? HTMLPurifier is essentially broken on PHP 7.2 presently, which is general release and thus has to be supported in most projects.

@ezyang
Copy link
Owner

ezyang commented Feb 23, 2018

4.10.0 is out.

@guruskid
Copy link

replace line 45
function __autoload($classname)
{
PHPMailerAutoload($classname);
}

with

spl_autoload_register(function($class) {
PHPMailerAutoload($classname);
});

@SmartGuyCodes
Copy link

SmartGuyCodes commented Apr 6, 2022

Auto load classes

1. OLD WAY EXAMPLE

function __autoload($className){
	if(file_exists(DIR_FS_CLASSES . "class." . $className . ".php"))
		include DIR_FS_CLASSES . "class." . $className . ".php";
}

2. NEW WAY EXAMPLE

spl_autoload_register(function($className) {
    if(file_exists(DIR_FS_CLASSES . "class." . $className . ".php"))
		include DIR_FS_CLASSES . "class." . $className . ".php";
});

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

6 participants