• Resolved Compute

    (@compute)


    wp option get siteurl

    PHP Warning:  include_once(/addtoany.widgets.php): failed to open stream: No such file or directory in .../wp-content/plugins/add-to-any/add-to-any.php on line 1116
    Warning: include_once(/addtoany.widgets.php): failed to open stream: No such file or directory in .../wp-content/plugins/add-to-any/add-to-any.php on line 1116
    PHP Warning:  include_once(): Failed opening '/addtoany.widgets.php' for inclusion (include_path='/srv/www/wp-cli/vendor/phpunit/phpunit-mock-objects:/srv/www/wp-cli/vendor/phpunit/php-token-stream:/srv/www/wp-cli/vendor/phpunit/php-code-coverage:/srv/www/wp-cli/vendor/phpunit/phpunit:/srv/www/wp-cli/vendor/symfony/yaml:.:/usr/share/php:/usr/share/pear') in .../wp-content/plugins/add-to-any/add-to-any.php on line 1116
    Warning: include_once(): Failed opening '/addtoany.widgets.php' for inclusion (include_path='/srv/www/wp-cli/vendor/phpunit/phpunit-mock-objects:/srv/www/wp-cli/vendor/phpunit/php-token-stream:/srv/www/wp-cli/vendor/phpunit/php-code-coverage:/srv/www/wp-cli/vendor/phpunit/phpunit:/srv/www/wp-cli/vendor/symfony/yaml:.:/usr/share/php:/usr/share/pear') in .../wp-content/plugins/add-to-any/add-to-any.php on line 1116
    PHP Fatal error:  Class 'A2A_SHARE_SAVE_Widget' not found in .../wp/wp-includes/widgets.php on line 591
    Fatal error: Class 'A2A_SHARE_SAVE_Widget' not found in .../wp/wp-includes/widgets.php on line 591

    Seems like the global is getting a NULL. The current code:

    // WordPress Must-Use?
    if ( basename( dirname( __FILE__ ) ) == 'mu-plugins' ) {
    	// __FILE__ expected in /wp-content/mu-plugins (parent directory for auto-execution)
    	// /wp-content/mu-plugins/add-to-any
    	$A2A_SHARE_SAVE_plugin_url_path = WPMU_PLUGIN_URL . '/add-to-any';
    	$A2A_SHARE_SAVE_plugin_dir = WPMU_PLUGIN_DIR . '/add-to-any';
    }
    else {
    	// /wp-content/plugins/add-to-any
    	$A2A_SHARE_SAVE_plugin_url_path = WP_PLUGIN_URL . '/' . $A2A_SHARE_SAVE_plugin_basename;
    	$A2A_SHARE_SAVE_plugin_dir = WP_PLUGIN_DIR . '/' . $A2A_SHARE_SAVE_plugin_basename;
    }

    If you instead access the global before setting it, it works:

    global $A2A_SHARE_SAVE_plugin_dir;
    
    // WordPress Must-Use?
    if ( basename( dirname( __FILE__ ) ) == 'mu-plugins' ) {
    	// __FILE__ expected in /wp-content/mu-plugins (parent directory for auto-execution)
    	// /wp-content/mu-plugins/add-to-any
    	$A2A_SHARE_SAVE_plugin_url_path = WPMU_PLUGIN_URL . '/add-to-any';
    	$A2A_SHARE_SAVE_plugin_dir = WPMU_PLUGIN_DIR . '/add-to-any';
    }
    else {
    	// /wp-content/plugins/add-to-any
    	$A2A_SHARE_SAVE_plugin_url_path = WP_PLUGIN_URL . '/' . $A2A_SHARE_SAVE_plugin_basename;
    	$A2A_SHARE_SAVE_plugin_dir = WP_PLUGIN_DIR . '/' . $A2A_SHARE_SAVE_plugin_basename;
    }

    https://www.ads-software.com/plugins/add-to-any/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author micropat

    (@micropat)

    Unable to reproduce in WP-CLI 0.20.2 against stable core WP.

    $A2A_SHARE_SAVE_plugin_dir is already set in the global scope, so there’s probably something else causing the issue you’re seeing.

    Thread Starter Compute

    (@compute)

    Still getting the error on WP-CLI 0.21.0-alpha, PHP 5.5.

    Using the varying vagrant vagrants box:
    https://github.com/Varying-Vagrant-Vagrants/VVV

    Thread Starter Compute

    (@compute)

    Still breaking on WP-CLI 0.21.0, PHP 5.5

    Hi there—
    I’m getting the same error with WP-CLI 0.21.0, PHP 5.5.9.

    Plugin Author micropat

    (@micropat)

    This is a WP-CLI issue, not an AddToAny issue.

    Using a reduced test case, WP-CLI 0.21.0 fails, but WP-CLI 0.20.2 worked.

    // Already global scope, so the global keyword isn't used.
    //global $a_global_var;
    
    $a_global_var = 'Of course.';
    
    function foo() {
    	global $a_global_var;
    
    	if ( empty( $a_global_var ) ) {
    		$a_global_var = 'Nope!';
    	}
    
    	die( 'Is global scope behaving? ' . $a_global_var . " \n" );
    }
    
    foo();

    Please report this to WP-CLI.

    Hi @micropat,

    I’m the maintainer of WP-CLI. In v0.21.0, we switched WP-CLI to load WordPress inside of a function. This means any global variables need to be explicitly globalized, which is a pattern WordPress core already follows.

    Can you explicitly globalize the global variables in your plugin?

    Thanks

    Plugin Author micropat

    (@micropat)

    Thanks Daniel, I suspected that might be the case. The next plugin release will explicitly globalize those global vars.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘$A2A_SHARE_SAVE_plugin_dir not set and breaks WP CLI’ is closed to new replies.