• Resolved janthiel

    (@janthiel)


    Hi there,

    we just updated a multisite installation from WP Mail SMTP 2.7.0 to 3.0.3. After the upgrade we have the logs full of this errors:

    WPMailSMTP\Admin\DebugEvents\Event->save 
    PHP message: WordPress-Datenbank-Fehler Table 'wp_<ID>_wpmailsmtp_debug_events' doesn't exist für Abfrage SELECT * FROM wp_<ID>_wpmailsmtp_debug_events

    They occur for all sites we have in the Multisite.

    Seems the new tables for the v3 features are not created on the sites while the update process.
    Any suggestion how to fix this?

    Thanks,
    Jan

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Gregor Capuder

    (@capuderg)

    Hi Jan,

    the tables are only created once the WP dashboard of that site is visited. We don’t want to execute the check for migration tasks (DB table creation) on each frontend request, that’s why they are executed on the admin_init hook. This hook only runs in the admin dashboard.

    Please test it out, by logging into the admin dashboard of one of your subsites. That should run the migration and create the DB table for that subsite.

    The WP site without that DB table should still work OK, just the DB errors will be logged.

    Take care!

    Thread Starter janthiel

    (@janthiel)

    @capuderg Thanks for the details ??

    We run and maintain > 100 sites in the Multisite with the plugin. Any chance to provide a WP-CLI command for the DB update with one of the next updates?
    Logging in to each of these sites after updates is quite ineffective and contrary to our any automation deployment strategy.
    WP-CLI would reduce the efford to a 1 line shell script and about 1 minute “work”.

    Thanks alot and best regards,
    Jan

    Plugin Author Gregor Capuder

    (@capuderg)

    Hi Jan,

    you could also run the plugin migrations by running wp_mail_smtp()->init_migrations(). We added this method in v3.0.

    So, adding something like this code below would run the migrations once a day and they would be triggered by frontend requests as well:

    
    // Fire DB migrations once per day on "init" action instead of "admin_init" for correct DB tables creation on subsites.
    if (
    	! \WPMailSMTP\WP::in_wp_admin() &&
    	! \WPMailSMTP\WP::is_doing_ajax() &&
            is_multisite() &&
    	! is_network_admin() &&
    	! wp_doing_cron() &&
    	! get_transient( 'wp_mail_smtp_multisite_init_migrations_daily' )
    ) {
    	remove_action( 'admin_init', [ wp_mail_smtp(), 'init_migrations' ] );
    	add_action( 'init', [ wp_mail_smtp(), 'init_migrations' ] );
    	set_transient( 'wp_mail_smtp_multisite_init_migrations_daily', true, DAY_IN_SECONDS );
    }
    

    As long as your subsites have some traffic, the migrations should run within a day or two.

    Let me know if that will resolve your issues.

    Take care!

    • This reply was modified 3 years, 2 months ago by Gregor Capuder. Reason: added is_multisite() check
    Thread Starter janthiel

    (@janthiel)

    @capuderg Thanks for the input. That are all information relevant to solve the migration using WP-CLI ??

    For anyone asking or searching: In a WordPress Multisite you can run the DB migration in all sites with this command:

    wp site list --field=url | xargs -n1 -I % wp --url=% eval 'if (function_exists("wp_mail_smtp")) { wp_mail_smtp()->init_migrations(); }'

    Best,
    Jan

    Plugin Author Gregor Capuder

    (@capuderg)

    Hi Jan,

    thank you for sharing the WP CLI solution with others.

    I just want to point out, that this is only possible with WP Mail SMTP v3.0 or higher (before this version, the init_migrations method did not exist).

    Thanks again and have a nice day!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wpmailsmtp_debug_events tables missing’ is closed to new replies.