Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postponed blog detection on WP >= 4.6 #590

Closed

Conversation

stodorovic
Copy link

@donnchawp
Copy link
Contributor

It simplifies things but does it fix a problem on MS sites?

@stodorovic
Copy link
Author

It should be first step. Main change is:

if ( is_multisite() && $wpsc_wp_gte_46 && empty( $wp_super_cache_late_init ) ) {
	add_action( 'ms_loaded', 'wp_cache_serve_cache_file' );
}

wp_cache_serve_cache_file runs again wp-cache-base.php and get correct blog_id. Also WP_ALLOW_MULTISITE isn't good for detection ( #97 - correct constant is MULTISITE and is_multisite uses it).

For test, I've added code:

        // Fixes $blogcacheid and $blog_cache_dir if ms-settings.php is loaded.
        if ( is_multisite() && is_object( $current_blog ) ) {
                $old_blogcacheid =  $blogcacheid;
                $old_blog_cache_dir = $blog_cache_dir;
                require WPCACHEHOME . 'wp-cache-base.php';
                if ( $old_blogcacheid !=  $blogcacheid || $old_blog_cache_dir = $blog_cache_dir ) {
                        $duration = wp_cache_microtime_diff($GLOBALS['wp_start_time'], microtime()) * 1000;
                        $duration = sprintf("%.0f", $duration);
                        wp_cache_debug( 'Blog ID/Dir changed (ms_loaded delay - '.$duration.'ms): '. $old_blogcacheid.'=>'.$blogcacheid.' '.$old_blog_cache_dir.'=>'.$blog_cache_dir );
                }
        }

One example:
http://www.example.com/category/test

17:20:23 5467 /category/test/ Blog ID/Dir changed (ms_loaded delay - 26ms): category=>blog /home/.../wp-content/cache/blogs/category/=>/home/.../wp-content/cache/blogs/blog/

Main issue is "delete cache" (these blogs - category in example don't exist). I'm not sure for other side effects.

Anyway, it needs more testing, but I think that this will fix main issues. I'm still working on it and I'm cleaning old code. Also, I'll try to re-read issues on wordpress.org. Maybe I figure out more details.

@donnchawp
Copy link
Contributor

I merged #592 first because this touches a lot of code and looks like it'll be hard to test fully.

I also want to get a quick fix out for the fatal error updating posts.

@stodorovic
Copy link
Author

No problem. I agree that's hard to check. I'm planning to split into couple PRs.

@stodorovic
Copy link
Author

I just created #600 which contains one part of this PR.

@stodorovic
Copy link
Author

Closing this in favor of #600, #602 and #606.

@stodorovic stodorovic closed this Sep 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants