• I got this error when ever automatic transaction happens –
    [21-Apr-2021 21:42:10 UTC] WordPress database error Table ‘testdbase.a’ doesn’t exist for query SELECT a.action_id FROM a WHERE 1=1 AND a.hook=’wp_mail_smtp_send_usage_data’…. bla bla bla…

    I am using latest WordPress version 5.7.1 and WP Mail SMTP version 2.7.0.
    Also all the actionscheduler tables are created in the database.

    Responsible file for this error :- \wp-content\plugins\wp-mail-smtp\vendor\woocommerce\action-scheduler\classes\data-stores\ActionScheduler_DBStore.php

    Responsible code line for this error – 290
    Which is :- $sql .= ” FROM {$wpdb->actionscheduler_actions} a”;

    Troubleshooting – When we hard code the table name instead of {$wpdb->actionscheduler_actions} the error goes off.

    Eg:- $sql .= ” FROM xxxx_actionscheduler_actions a”;
    (xxxx_ is the table prefix)

    Solution for this (Recommended by WordPress) :
    global $wpdb;
    $table_name = $wpdb->prefix . ‘actionscheduler_actions’;
    $sql .= ” FROM {$table_name} a”;

    Note: Here table prefix is retrieved separately and then concatenate it to the table name. Only then after it is added to the query.
    Please refer – https://codex.ww.wp.xz.cn/Creating_Tables_with_Plugins#Database_Table_Prefix
    Another incident similar to this – https://stackoverflow.com/questions/12566072/wpdb-table-name

    IMPORTANT NOTE TO PLUGIN DEVELOPERS: There are many places of this plugin code on which table name is retrieved same as {$wpdb->actionscheduler_actions} and then assigned to a sql alias to build the required query. Which means sooner or later many of your plugin users will come up with this type of error/problem. So i am suggesting you guys to update required places of your plugin code with this WordPress recommended practice of retrieving table names. Fixing this issue now will save lots of time and effort of you guys and users.

    Thanks.
    Anjana Hemachandra

Viewing 1 replies (of 1 total)
  • Hi Anjana,

    Thanks for reaching out and sharing your feedback. It looks like the suggestion is for the Action Scheduler library that is bundled within WP Mail SMTP. Could you please open up an issue about this on their GitHub repo? That’s where the Action Scheduler developers track and triage the issues.

    Thanks!

Viewing 1 replies (of 1 total)

The topic ‘Table doesn’t exist error – solution for it (Need to improve the plugin)’ is closed to new replies.