Fatal error with RWMB_About::redirect()

Support General Fatal error with RWMB_About::redirect()Resolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #15501
    onpconpc
    Participant

    Hello,

    I noticed a PHP Fatal Error with RWMB_About::redirect().
    If we use a php function to update the row in database for activated plugins, it automatically launches the function redirect() of the class RWMB_About. As if it considered a new activation of the plugin MB.

    It looks the issue is due to the Hook do_action( 'activate_plugin', trim( $plugin ) );

    here's an example of the trace :

    PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function RWMB_About::redirect(), 1 passed in [...]/wp-includes/class-wp-hook.php on line 286 and exactly 2 expected in [...]/wp-content/plugins/meta-box/inc/about/about.php:155
    Stack trace:
    #0 [...]/wp-includes/class-wp-hook.php(286): RWMB_About->redirect('search-and-repl...')
    #1 [...]/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array)
    #2 [...]/wp-includes/plugin.php(465): WP_Hook->do_action(Array)
    #3 [...]/wp-content/plugins/blob/blob.php(245): do_action('activated_plugi...', 'search-and-repl...')
    #4 [...]/wp-content/plugins/blob/blob.php(128): Blob->run_activate_plugin('search-and-repl...')
    #5 [...]/wp-includes/class-wp-hook.php(286): Blob->blob('')
    #6 /srv/data/web/vho in [...]/wp-content/plugins/meta-box/inc/about/about.php on line 155

    How to avoid the function RWMB_About::redirect() to be launched ?

    Environnement :
    WPMU 5.2.2
    PHP 7.2

    #15502
    onpconpc
    Participant

    Please ! It is really urgent ! A lot of our home plugins do not work anymore !

    Here is the fatal combo :

    do_action( 'activate_plugin', trim( $plugin ) );
    update_option( 'active_plugins', $current );
    do_action( 'activate_' . trim( $plugin ) );
    do_action( 'activated_plugin', trim( $plugin) );

    The last line of the code launches add_action( 'activated_plugin', array( $this, 'redirect' ), 10, 2 ); in the init() function of the class RWMB_About

    #15503
    onpconpc
    Participant

    Found the issue :

    /**
         * Redirect to about page after Meta Box has been activated.
         *
         * @param string $plugin       Path to the main plugin file from plugins directory.
         * @param bool   $network_wide Whether to enable the plugin for all sites in the network
         *                             or just the current site. Multisite only. Default is false.
         */
        public function redirect( $plugin, $network_wide ) {
            if ( 'cli' !== php_sapi_name() && ! $network_wide && 'meta-box/meta-box.php' === $plugin && ! $this->is_bundled() ) {
                wp_safe_redirect( $this->get_menu_link() );
                die;
            }
        }

    $network_wide is not set to false by default
    we should have
    public function redirect( $plugin, $network_wide = false ) {

    #15520
    Anh TranAnh Tran
    Keymaster

    Hi, I saw your pull request on Github and have merged it.

    Thanks a lot for your feedback and contribution. I'll release a new version with this fix soon.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.