From fdd3129dd8ab82a70f23cb24fa89586fed6970a1 Mon Sep 17 00:00:00 2001 From: Utkarsh Patel Date: Fri, 3 Jul 2026 13:10:18 +0530 Subject: [PATCH] Avoid re-running full plugin init during activation install() called get_plugin_instance()->init() unconditionally, which re-ran the bootstrap out of sequence during plugin activation and could destabilise plugin load order for the request (e.g. triggering ACF to initialise too early). Only run init() when the plugin version has not already been populated; the DB routines only need the version. --- php/class-utils.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/php/class-utils.php b/php/class-utils.php index d733479a8..83c3282fd 100644 --- a/php/class-utils.php +++ b/php/class-utils.php @@ -334,8 +334,17 @@ protected static function table_installed() { * Install our custom table. */ public static function install() { - // Ensure that the plugin bootstrap is loaded. - get_plugin_instance()->init(); + $plugin = get_plugin_instance(); + + // Ensure the plugin metadata (version, paths) is available for the DB + // routines below, but avoid re-running init during activation when it has + // already run on the `init` hook. Re-running the full bootstrap out of + // sequence during activation can destabilise plugin load order for the + // request (e.g. triggering other plugins such as ACF to initialise too + // early). We only need the plugin version here, not the component graph. + if ( empty( $plugin->version ) ) { + $plugin->init(); + } $sql = self::get_table_sql();