• Resolved Daniel Iser

    (@danieliser)


    I have all debug enabled both in WP & PHP.

    Getting this on activation.

    Strict Standards: Declaration of statisticsPps::getTypeId() should be compatible with modulePps::getTypeID() in wp-content\plugins\popup-by-supsystic\modules\statistics\mod.php on line 19

    Also getting The plugin generated 3292 characters of unexpected output during activation.

    https://www.ads-software.com/plugins/popup-by-supsystic/

Viewing 7 replies - 16 through 22 (of 22 total)
  • Thread Starter Daniel Iser

    (@danieliser)

    @supsystic.com Will confirm they are fixed shortly and close the issue.

    Thread Starter Daniel Iser

    (@danieliser)

    Just tried this on 3 different installs. If wp_debug is enabled there is still text generated during activation.

    I have tracked the problem to these lines in the frameFPS::init method

    register_activation_hook(  PPS_DIR. DS. PPS_MAIN_FILE, array('utilsPps', 'activatePlugin')  ); //See classes/install.php file
    register_uninstall_hook(PPS_DIR. DS. PPS_MAIN_FILE, array('utilsPps', 'deletePlugin'));

    After some digging I found the issue. You are calling a non static method activatePlugin statically. This leads to a php error which is printed to the browser causing output during activation.

    Same for the deletePlugin method.

    Changing the function to public static function activatePlugin() fixes the activation issues.

    Plugin Author supsystic

    (@supsysticcom)

    Hello.
    Really – thank you for this clarification. We enabled all debug modes – for WordPress and PHP serve – but didn’t saw those warnings, maybe this is depends on PHP version – as method can be static if it is just don’t use any $this. In any case – we will fix this in next release, I think – on next week.

    Thread Starter Daniel Iser

    (@danieliser)

    Not a problem.

    Just an FYI, when using classes in actions such as activation hooks there are a couple rules.

    If it is a static method, call it like you are.

    add_action( 'init', array( 'class', 'method' ) );

    If it is a non static method it has to be called via an instance of the class like so.

    $class = new MyClass;
    add_action( 'init', array( $class, 'method' ) );

    Or if its being called inside the class itself, say in the __construct or init methods you can do it like this.

    add_action( 'init', array( $this, 'method' ) );

    The catch though with calling it from instance based classes ( the second 2 above ) is that if it ever needs to be unhooked you have to pass in the same instance and not a new one.

    For example

    This will work.

    $class = new MyClass;
    add_action( 'init', array( $class, 'method' ) );
    remove_action( 'init', array( $class, 'method' ) );

    This won’t.

    $class = new MyClass;
    add_action( 'init', array( $class, 'method' ) );
    
    $new_instance = new MyClass;
    remove_action( 'init', array( $new_instance , 'method' ) );

    So in the example above you may want to store the $class variable as a global, allowing you to later use it again like so.

    global $class;
    remove_action( 'init', array( $class, 'method' ) );

    Hope this helps in the future.

    Thread Starter Daniel Iser

    (@danieliser)

    Also try adding this to your wp-config.php file for your development site. It will guarantee you find all the bugs ( not usability bugs, just errors ) before releasing.

    define('WP_DEBUG', true);
    if (WP_DEBUG) {
    	define('WP_DEBUG_LOG', true);
    	define('WP_DEBUG_DISPLAY', true);
    	@ini_set('display_errors', 0);
    }
    Plugin Author supsystic

    (@supsysticcom)

    Hello.
    Thank you for clarifications about callbacks for WordPress events calling, now it is more clear for us. But in last example:
    @ini_set(‘display_errors’, 0);
    Maybe it should be @ini_set(‘display_errors’, 1); ?

    Thread Starter Daniel Iser

    (@danieliser)

    @supsystic.com Valid point. I think setting it to 0 is done because WP has built in PHP error handling meaning setting it to 1 would show errors twice, but test it and let me know.

    I generally run all development with those lines and Debug Bar plugin and usually can find all errors during development and before release.

    PS glad to help.

Viewing 7 replies - 16 through 22 (of 22 total)
  • The topic ‘Lots of errors on activation’ is closed to new replies.