• On my staging network, I try to activate for one site only.

    web@staging:/var/www/zzz$ wp plugin deactivate cf-images --network
    Plugin 'cf-images' network deactivated.
    Success: Network deactivated 1 of 1 plugins.
    web@staging:/var/www/zzz$ wp plugin activate cf-images --url=zzz
    Plugin 'cf-images' network activated.
    Success: Activated 1 of 1 plugins.


    OK, so it overrides that and installs network-wide. This is an issue because it causes page loads of around 10 seconds. Query Monitor shows 1398 requests from this plugin using switch_to_blog and restore_current_blog

    switch_to_blog(1)87 → 1+
    CF_Images\A\M\Multisite->network_settings()
    Plugin: cf-images

    restore_current_blog()87 ← 1+
    CF_Images\A\M\Multisite->network_settings()

      I’ve tried with “Network wide settings” option enabled and disabled but same issue. This is with version 1.9.5 on WP 6.8.1 and PHP 8.4.2.


    Viewing 2 replies - 1 through 2 (of 2 total)
    • Thread Starter ablears

      (@ablears)

      The issue is with network_settings in app/modules/class-multisite.php

      The current logic unconditionally pulls the main site’s settings on sub-sites, regardless of value for cf-images-network-wide.

      • This reply was modified 10 months, 1 week ago by ablears.
      Plugin Author Anton Vanyukov

      (@vanyukov)

      Hi @ablears,

      Thanks for flagging this. I’ve tested this, and it should be easier to just rely on the network settings, instead of trying to fetch the settings from the main blog. Can you please see if this fixes the issue for you: https://github.com/av3nger/cf-images/commit/47a97f964ca291ccbcc85aa488fbeb864e627511

      You should be able to replace

      $main_site_id = get_main_site_id();

      switch_to_blog( $main_site_id );

      $settings = get_option( 'cf-images-settings', Settings::get_defaults() );

      restore_current_blog();

      return $settings;

      in app/modules/class-multisite.php with just

      return get_site_option( 'cf-images-settings', Settings::get_defaults() );

      Best regards,
      Anton

    Viewing 2 replies - 1 through 2 (of 2 total)

    The topic ‘Multisite install causing slowdown with switch_to_blog’ is closed to new replies.