• Resolved Bizberg Themes

    (@bizbergthemes)


    Cache regeneration is not working in multisite. when i check the database request_uri is this /test/wp-json/v1/app-settings

    i checked the $url variable in regenerate_expired_caches() function. The $url is like this example.com/test/test/wp-json/v1/app-settings

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Richard Korthuis

    (@rockfire)

    Hi @bizbergthemes

    Thank you for using our plugin!

    We just released a new version of our plugin, which should solve this issue.

    Thread Starter Bizberg Themes

    (@bizbergthemes)

    I have updated the plugin but it not generating the expired cache. The problem is in includes/caching/class-caching.php.

    public function regenerate_expired_caches() {
        global $wpdb;
        $regenerate_number = (int) $this->get_regenerate_number();
        $sql =
            "SELECT * 
            FROM {$this->db_table_caches}
            WHERE cache_type = 'endpoint'
            ORDER BY cache_hits DESC";
        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
        $results = $wpdb->get_results( $sql, ARRAY_A );
        foreach ( $results as &$result ) {
            if ( 1 === strtotime( $result['expiration'] ) || false === get_transient( $this->transient_key( $result['cache_key'] ) ) ) {
                // Regenerate.
                $url    = Util::get_home_url() . $result['request_uri'];
                $return = wp_remote_get(
                    $url,
                    [
                        'timeout'   => 10,
                        'sslverify' => false,
                        'headers'   => json_decode( $result['request_headers'], true ),
                    ]
                );
    
                --$regenerate_number;
                if ( $regenerate_number <= 0 ) {
                    break;
                }
            }
        }
    }

    The problem is in this code $url = Util::get_home_url() . $result['request_uri'];

    in multisite the link is like this https://example.com/wordpress/wordpress/wp-json/v1/…&#8230; if i print $url but it should be https://example.com/wordpress/wp-json/v1/…&#8230;

    Plugin Author Richard Korthuis

    (@rockfire)

    Hi @bizbergthemes

    Maybe I should have mentioned you have to delete all old caches first, because they are saved with the wrong request uri in the database. So in your example it is saved as /wordpress/wp-json/... where it should be saved as /wp-json/...
    Sorry for not mentioning that yesterday.

    Thread Starter Bizberg Themes

    (@bizbergthemes)

    yes now it is working.

    Thank you

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

The topic ‘Problem in regenerating cache in multisite’ is closed to new replies.