• I found a reproducible compatibility issue between WPCode and Modular DS on a WordPress multisite installation. Environment

    • WordPress multisite
    • PHP 8.2
    • WPCode version 2.3.8
    • WPCode network-activated
    • Modular Connector version 3.0.2
    • nginx
    • Cloudflare
    • Modular DS connects through a request to:
    /wp-load.php?code=...&origin=mo&type=oauth

    Problem

    When WPCode is network-active, the Modular DS OAuth request returns HTTP 500.

    The exact fatal recorded by Modular Connector is:

    production.ERROR: Class "WPCode_File_Cache" not found
    
    Error location:
    wp-content/plugins/insert-headers-and-footers/ihaf.php:436

    Stack trace:

    #0 wp-includes/class-wp-hook.php(341): WPCode->load_components()
    #1 wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters()
    #2 wp-includes/plugin.php(522): WP_Hook->do_action()
    #3 wp-settings.php(622): do_action()
    #4 wp-config.php: require_once(...)
    #5 wp-load.php: require_once(...)

    After manually preloading that class, the fatal advances to other WPCode admin-only classes, including:

    Class "WPCode_Library" not found
    Class "WPCode_Admin_Page_Loader_Lite" not found
    Class "WPCode_Smart_Tags_Lite" not found

    Apparent cause

    In ihaf.php, WPCode loads admin-only class files inside this condition:

    if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
    	require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-file-cache.php';
    	require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-library.php';
    	// Other admin classes...
    }

    Later, WPCode::load_components() uses the same condition and instantiates those classes:

    if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
    	$this->file_cache   = new WPCode_File_Cache();
    	$this->library      = new WPCode_Library();
    	$this->library_auth = new WPCode_Library_Auth();
    	// Other admin components...
    }

    Modular DS initially enters through wp-load.php, so is_admin() appears to be false when WPCode runs its includes() method.

    Modular Connector later defines WP_ADMIN during its request pipeline. By the time WPCode’s load_components() callback runs on plugins_loaded, is_admin() is true, so WPCode tries to instantiate admin classes that were skipped earlier.

    This creates a state mismatch:

    WPCode includes phase:
    is_admin() = false
    Admin files are not loaded
    
    WPCode load_components phase:
    is_admin() = true
    Admin classes are instantiated
    Fatal: class not found

    Reproduction

    1. Network-activate WPCode.
    2. Start a Modular DS OAuth connection.
    3. Modular requests:
    /wp-load.php?code=...&origin=mo&type=oauth
    1. The request returns HTTP 500.
    2. The WPCode class-not-found fatal is logged.

    Confirmation

    When WPCode is network-deactivated, Modular DS connects successfully immediately.

    Reinstalling WPCode 2.3.8 did not resolve the issue. Suggested fix

    WPCode should avoid evaluating is_admin() independently during two different bootstrap stages.

    Possible fixes may include:

    • loading all classes required by load_components() unconditionally;
    • storing the initial admin-state decision and using the same value in both includes() and load_components();
    • checking that each class exists before instantiating it;
    • moving the admin includes into load_components() immediately before instantiation.

    For example:

    if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
    	if ( ! class_exists( 'WPCode_File_Cache', false ) ) {
    		require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-file-cache.php';
    	}
    
    	$this->file_cache = new WPCode_File_Cache();
    }

    Please let me know if you need the full Modular Connector log or additional server details.

Viewing 1 replies (of 1 total)
  • Plugin Support markomiljanovic

    (@markomiljanovic)

    @graphiclux,

    Thank you for reaching out, and genuinely thank you for such a thorough report.

    We’re working on reproducing it on our end with Modular Connector now, and I’ve passed it along to the development team to look into. I’ll follow up here as soon as I have something concrete to share.

    If the reproduction turns up anything unexpected, I may come back and ask for that full Modular Connector log.

    Thanks,

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.