Support » Plugin: W3 Total Cache » New update 0.9.7.4 breaks multisite setup

  • Resolved edemir206

    (@edemir206)


    Hi,

    Tryied to update to new version but it is breaking our multisite rewrite rules, when acessing a subsite it gives me an error 404 not found.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Marko Vasiljevic

    (@vmarko)

    Hello,

    Go to your Network Admin site and configure W3TC there. On the Performance –> General Settings Tab, scroll down to the Miscellaneous section near the bottom. There, you need to uncheck “Use single network configuration file for all sites.”
    See if the issue persists.

    Hi,

    Your fix didn’t work, but I found a fix.

    The logs:

    2019/05/16 08:00:33 [error] 520#520: *129169 FastCGI sent in stderr: "PHP message: Erro de banco de dados do WordPress You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'OR (domain = 'www.ufsm.br' AND path = '/midias/') OR (domain = 'www.ufsm.br' at line 1 para a consulta OR (domain = 'www.ufsm.br' AND path = '/midias/') OR (domain = 'www.ufsm.br' AND path = '/midias/arco/') OR (domain = 'www.ufsm.br' AND path = '/midias/arco/2019/') OR (domain = 'www.ufsm.br' AND path = '/midias/arco/2019/05/') OR (domain = 'www.ufsm.br' AND path = '/midias/arco/2019/05/10/') OR (domain = 'www.ufsm.br' AND path = '/midias/arco/2019/05/10/algoritmo-atento-como-a-tecnologia-organiza-e-direciona-informacoes-dos-usuarios-da-web-em-perfis-comerciais/') ORDER BY pathlen DESC LIMIT 1 feita por require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), require('wp-includes/ms-settings.php'), include_once('/sunrise.php'), W3TC\" while reading response header from upstream, server: www.ufsm.br, request: "GET /midias/arco/2019/05/10/algoritmo-atento-como-a-tecnologia-organiza-e-direciona-informacoes-dos-usuarios-da-web-em-perfis-comerciais/ HTTP/1.0", upstream: "fastcgi://unix:/var/run/php7-fpm-www.sock:", host: "www.ufsm.br", referrer: "https://www.ufsm.br/"

    We use the “sunrise.php” for multisite nested paths.

    <?php
    
    if( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) {
        $current_site = new stdClass();
        $current_site->id = (defined( 'SITE_ID_CURRENT_SITE' ) ? constant('SITE_ID_CURRENT_SITE') : 1);
        $current_site->domain = $domain = DOMAIN_CURRENT_SITE;
        $domain = $current_site->domain;
        $current_site->path  = $path = PATH_CURRENT_SITE;
    
        if( defined( 'BLOGID_CURRENT_SITE' ) )
            $current_site->blog_id = BLOGID_CURRENT_SITE;
     
        $url = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
     
        $patharray = (array) explode( '/', trim( $url, '/' ));
        $blogsearch = '';
    
        if( count( $patharray )){
            foreach( $patharray as $pathpart ){
                $pathsearch .= '/'. $pathpart;
                $blogsearch .= $wpdb->prepare(" OR (domain = %s AND path = %s) ", $domain, $pathsearch .'/' );
            }
        }
    
        $current_blog = $wpdb->get_row( $wpdb->prepare("SELECT *, LENGTH( path ) as pathlen FROM $wpdb->blogs WHERE domain = %s AND path = '/' ", $domain, $path) . $blogsearch .'ORDER BY pathlen DESC LIMIT 1');
    
     
        $blog_id = $current_blog->blog_id;
        $public  = $current_blog->public;
        $site_id = $current_blog->site_id;
    
        $current_site = pu_get_current_site_name( $current_site );
    }
    
    function pu_get_current_site_name( $current_site ) {
        global $wpdb;
        $current_site->site_name = wp_cache_get( $current_site->id . ':current_site_name', "site-options" );
        if ( !$current_site->site_name ) {
            $current_site->site_name = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = %d AND meta_key = 'site_name'", $current_site->id ) );
            if( $current_site->site_name == null )
                $current_site->site_name = ucfirst( $current_site->domain );
            wp_cache_set( $current_site->id . ':current_site_name', $current_site->site_name, 'site-options');
        }
        return $current_site;
    }

    The problem was that in this line:

    $current_blog = $wpdb->get_row( $wpdb->prepare("SELECT *, LENGTH( path ) as pathlen FROM $wpdb->blogs WHERE domain = %s AND path = '/' ", $domain, $path) . $blogsearch .'ORDER BY pathlen DESC LIMIT 1');

    Changing to:

    $current_blog = $wpdb->get_row( $wpdb->prepare("SELECT *, LENGTH( path ) as pathlen FROM $wpdb->blogs WHERE domain = %s AND path = '%s' ", $domain, $path) . $blogsearch .'ORDER BY pathlen DESC LIMIT 1');

    Not sure yet what impact it will have in our setup, need to test in my staging env but it’s working now.

    Plugin Support Marko Vasiljevic

    (@vmarko)

    Hello,
    Thanks for the info.
    Please let us know if this resolves your issue.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘New update 0.9.7.4 breaks multisite setup’ is closed to new replies.