awesomemotive / WP-Mail-SMTP

The most popular WordPress SMTP and PHP Mailer plugin. Trusted by over 3 million sites.
https://wordpress.org/plugins/wp-mail-smtp/
GNU General Public License v3.0
55 stars 34 forks source link

ActionScheduler_ListTable does not setup WP_Screen correctly #110

Closed sergeliatko closed 2 years ago

sergeliatko commented 2 years ago

Expected Behavior

ActionScheduler_ListTable->get_primary_column_name( ) uses WP filter list_table_primary_column and must pass 2 parameters:

  1. @param string $default Column name default for the specific list table, e.g. 'name'.
  2. @param string $context Screen ID for specific list table, e.g. 'plugins'.

Both typed as string

Current Behavior

Second parameter $context (WP_Screen ID) is currently passed as null, breaking your Scheduled Actions list table when other plugins add their functions to the list_table_primary_column filter with strong type parameters.

Possible Solution

ActionScheduler_ListTable constructor does not pass the screen in args for parent contructor WP_List_Table and the parent's recovery mechanism for screen setup somehow fails.

Steps to Reproduce

  1. Paste this into functions.php file of the theme in default WP installation
//test WP Mail SMTP 'Scheduled Actions' table failure
add_filter(
    'list_table_primary_column',
    function ( string $default, string $context ) {
        return $default;
    },
    10,
    2
);

I know it may be WooCommerce ActionScheduler package responsibility but it is used in your plugin. Thanks.

capuderg commented 2 years ago

Hi @sergeliatko,

thank you very much for reporting this issue.

We've looked into it and already resolved it in our main plugin repository.

This fix will be available in the next plugin update.

If you need a temporary fix, you can edit the line in this method: \WPMailSMTP\Admin\Pages\ActionSchedulerTab::hooks, change this line:

add_action( 'admin_init', [ $this, 'init' ], 20 );

to:

add_action( 'current_screen', [ $this, 'init' ], 20 );

Thanks again and have a nice day!

sergeliatko commented 2 years ago

Thanks for the quick reply. I modified my plugin to accept null or string as a second parameter on that filter. It was just to let you know you might run into an incompatibility issue if someone uses the filter as per codex.

Thanks.

capuderg commented 2 years ago

We initiated the AS table too soon in the WP cycle, so the WP screen details were not available yet.

This fix will resolve any incompatibility issues with that filter.

Thank you again! 🎉

sergeliatko commented 2 years ago

Ok, got you. Good to know for my projects. You welcome. And thank you too.