$seeded ) { if ( array() === $seeded['tools'] ) { continue; } $server_id = self::empty_server_id( (string) $slug ); if ( 0 === $server_id ) { continue; } // DECLARED, exactly as the seeder would have written at INSERT. Not // `tools_for()` — that narrows to abilities registered right now, // which on a site without the add-on is the empty set that made // this repair necessary in the first place. CuratedToolWriter::add_missing( $server_id, $seeded['tools'] ); } update_option( self::DONE_OPTION, 1, false ); } /** * The id of a seeded server carrying NO curated rows, or 0. * * @since 0.3.6 * @param string $slug Seeded server slug. * @return int */ private static function empty_server_id( string $slug ): int { global $wpdb; $servers = $wpdb->prefix . 'acrossai_mcp_servers'; $tools = $wpdb->prefix . 'acrossai_mcp_server_tools'; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- One-shot upgrade path; no cache layer spans two plugin tables. $id = $wpdb->get_var( $wpdb->prepare( 'SELECT s.id FROM %i AS s WHERE s.server_slug = %s AND NOT EXISTS ( SELECT 1 FROM %i AS t WHERE t.server_id = s.id ) LIMIT 1', $servers, $slug, $tools ) ); return null === $id ? 0 : (int) $id; } }