Skip to content

Bug: missing event_automations table causes DB error on every request across multisite #1255

@superdav42

Description

@superdav42

Bug: Missing *_gratis_ai_agent_event_automations table on multisite subsites

Description

The plugin's AutomationsHandler->attach_event_hooks fires on every init for every subsite in the network, but the wp_NN_gratis_ai_agent_event_automations table doesn't exist on most subsites. This produces a DB error on every single request across the network.

Error

WordPress database error Table 'tgc_church_production.wp_NN_gratis_ai_agent_event_automations' doesn't exist
for query SELECT * FROM wp_NN_gratis_ai_agent_event_automations WHERE enabled = 1 ORDER BY name ASC
made by require('wp-load.php'), require_once('wp-settings.php'), do_action('init'),
  WP_Hook->do_action, WP_Hook->apply_filters,
  GratisAiAgent\Bootstrap\AutomationsHandler->attach_event_hooks,
  GratisAiAgent\Automations\EventTriggerHandler::attach_hooks,
  GratisAiAgent\Automations\EventAutomations::list,
  wpdb->get_results, wpdb->print_error

Affected subsites (sample)

wp_15, wp_18, wp_19, wp_32, wp_36, wp_37, wp_39, wp_40, wp_41, wp_42, wp_43, wp_44, wp_51

Expected behaviour

  1. The plugin should create the table on subsite activation (via switch_to_blog + dbDelta in a network-activation hook), OR
  2. EventAutomations::list should check $wpdb->get_var("SHOW TABLES LIKE '{$table}'") before querying, OR
  3. The plugin should only register event hooks on sites where it has been individually activated (not network-wide init)

Impact

  • Performance: unnecessary failed SQL query + PHP error handler invocation on every request for every affected subsite
  • Log noise: error log is filled exclusively with this error (hundreds of entries per minute), obscuring real errors
  • Disk: error log grows rapidly

Environment

  • WordPress 6.x multisite (subdomain mode, 50+ subsites)
  • PHP 8.4 / FrankenPHP
  • Plugin appears network-activated but tables only created on a subset of sites

aidevops.sh v3.14.11 plugin for OpenCode v1.3.17 with claude-sonnet-4-6 spent 2d 8h and 8 tokens on this as a headless worker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAuto-created from TODO.md tag

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions