Plugin Directory


Ignore:
Timestamp:
10/13/2026 10:00:51 AM (13 days ago)
Author:
shiponkarmakar
Message:

Release v1.1.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • optimazz/trunk/includes/Modules/Cache/Manager.php

    r3723128 r3743505  
    5454                }
    5555
     56                // Multisite: the drop-in, WP_CACHE, the engine config and .htaccess are
     57                // shared by the whole network and only Network::sync() (a network admin
     58                // action) writes them. A site writes just its own rules file and keeps
     59                // its own preload schedule in step with the network settings.
     60                if ( is_multisite() && ! \Optimazz\Core\Network::is_writing() ) {
     61                        \Optimazz\Core\Network::write_current_site_rules();
     62                        $on = ! empty( $cache_settings['enabled'] );
     63                        Preloader::schedule( $on && ! empty( $cache_settings['preload'] ), isset( $cache_settings['preload_interval'] ) ? (string) $cache_settings['preload_interval'] : 'twicedaily' );
     64                        if ( ! $on ) {
     65                                wp_clear_scheduled_hook( Preloader::HOOK . '_once' );
     66                                wp_clear_scheduled_hook( 'optimazz_purge_expired' );
     67                        }
     68                        Preloader::sync_due();
     69                        return;
     70                }
     71
    5672                // The engine config is a trimmed, disk-readable copy of the settings.
    5773                \Optimazz_Cache_Engine::write_config(
    … …  
    107123         */
    108124        public static function purge_and_rewarm() {
    109                 self::storage()->purge_all();
     125                if ( is_multisite() && ! \Optimazz\Core\Network::cache_enabled() ) {
     126                        return; // Page caching is off for this network — nothing to rebuild.
     127                }
     128                self::storage()->purge_all(); // On multisite: this site's pages only.
    110129
    111130                $cache = ( new \Optimazz\Core\Settings() )->for_module( 'cache' );
    … …  
    128147                }
    129148
     149                if ( is_multisite() ) {
     150                        // A new site has no rules file yet; write its own.
     151                        if ( ! is_readable( \Optimazz_Cache_Engine::site_rules_file( get_current_blog_id() ) ) ) {
     152                                \Optimazz\Core\Network::write_current_site_rules();
     153                        }
     154                        // Network caching is on but the shared drop-in or engine config is
     155                        // missing/stale (plugin folder moved, a host tool emptied the cache
     156                        // folder): heal it for the whole network — at most every 10 minutes,
     157                        // so a drop-in that can't be installed (another plugin owns it, the
     158                        // folder isn't writable) never makes every request run a full sync.
     159                        if ( ! empty( $cache_settings['enabled'] )
     160                                && null === Dropin::conflict_owner() // Another plugin's drop-in: nothing to heal (Network screen offers take-over).
     161                                && ( ! Dropin::is_current() || ! is_readable( \Optimazz_Cache_Engine::config_file() ) )
     162                                && ! get_site_transient( 'optimazz_heal' ) ) {
     163                                set_site_transient( 'optimazz_heal', 1, 10 * MINUTE_IN_SECONDS );
     164                                \Optimazz\Core\Network::queue_sync();
     165                        }
     166                        return;
     167                }
     168
    130169                if ( ! is_readable( \Optimazz_Cache_Engine::config_file() ) ) {
    131170                        self::sync( $cache_settings );
Note: See TracChangeset for help on using the changeset viewer.