WordPress.org

Ready to get started?Download WordPress

Forums

MailChimp Widget
[resolved] spl_autoload trying to autoload things outside it's scope (3 posts)

  1. sporkme
    Member
    Posted 3 years ago #

    Upgraded MC widget to 0.8.7, then WP to 3.2, not sure which one broke it.

    My error log is now full of errors and the widget no longer displays.

    Somewhat sanitized:

    [Sun Jul 10 03:39:11 2011] [error] [client] PHP Warning:  spl_autoload(): Unable to access sharepresspro.class.php in /var/www/sites/xxx/xxx/subdomains/staging/html/wp-content/plugins/mailchimp-widget/mailchimp-widget.php on line 42, referer: http://staging.xxx.xxx/?page_id=7
    [Sun Jul 10 03:39:11 2011] [error] [client] PHP Warning:  spl_autoload(): Unable to access sc_simple_meta_tags.class.php in /var/www/sites/xxx/xxx/subdomains/staging/html/wp-content/plugins/mailchimp-widget/mailchimp-widget.php on line 42, referer: http://staging.xxx.xxx/?page_id=7
    [Sun Jul 10 03:39:11 2011] [error] [client] PHP Warning:  spl_autoload(): Unable to access environment.class.php in /var/www/sites/xxx/xxx/subdomains/staging/html/wp-content/plugins/mailchimp-widget/mailchimp-widget.php on line 42, referer: http://staging.xxx.xxx/?page_id=7

    This is many lines long - what stood out for me is that it was trying to include a class from basically every installed plugin. This seems overly broad.

    If I just want a quick fix, what class files can I hardcode in to get this working?

    http://wordpress.org/extend/plugins/mailchimp-widget/

  2. jameslafferty
    Member
    Plugin Author

    Posted 3 years ago #

    Hi sporkme,

    spl_autoload attempts to load a class if it's not already defined. IMHO it's a better method for injecting class dependencies than require_once, include_once and the like.

    If you'd like to dispense with the autoloading, you can comment it out, then use require to include each of the class files in lib directly into the plugin folder.

    Something along these lines could work:

    /*
    set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/lib/'));
    
    spl_autoload_extensions('.class.php');
    
    if (! function_exists('buffered_autoloader')) {
    
    	function buffered_autoloader ($c) {
    
    		try {
    
    			spl_autoload($c);
    
    		} catch (Exception $e) {
    
    			$message = $e->getMessage();
    
    			return $message;
    
    		}
    
    	}
    
    }
    
    spl_autoload_register('buffered_autoloader');
    */
    require('lib/mcapi.class.php');
    require('lib/ns_mc_plugin.class.php');
    require('lib/ns_widget_mailchimp.class.php');

    Please let me know if that helps.

    Cheers,

    J.

  3. jameslafferty
    Member
    Plugin Author

    Posted 3 years ago #

    Marking this resolved as I haven't heard anything further about it.

    J.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic