spl_autoload_register function faulty
-
This function on the bottom of another-mailchimp-widget.php seems not to be programmed as such a spl_autoload ought to.
The buffered_autoloader function conflicted with Woocommerce. Some spl_autoload classes registered by Woocomerce were appended with .class.php by your code and reported not to be found on the server on the bottom of my live website.
This is your code:
public function buffered_autoloader( $class ) {
try {
set_include_path( get_include_path() . PATH_SEPARATOR . realpath( $this::get_plugin_dir() . ‘/lib/’ ) );
spl_autoload( $class, ‘.class.php’ );
ini_restore(‘include_path’);
} catch ( Exception $e ) {
$message = $e->getMessage();return $message;
}
}Examples for the simple way this code should look:
https://stackoverflow.com/questions/7651509/what-is-autoloading-how-do-you-use-spl-autoload-autoload-and-spl-autoload-re
or
https://syframework.alwaysdata.net/spl-autoload-registerI guess you encountered an issue with these simple examples while spl_autoload expects filenames with only lowercase and dashes for classes as written here:
https://wordpress.stackexchange.com/questions/158703/should-i-use-spl-autoload-register-in-my-pluginApart from the warning that appeared from this issue the subscription also encountered an unspecified error and there was no log or debug option to show what went wrong. It would be nice if the plugin would retrieve a list of audiences from Mailchimp to let you choose instead of just type the List ID.
The topic ‘spl_autoload_register function faulty’ is closed to new replies.