Skip to content

Commit

Permalink
Cache pagination pages properly (PR #7089)
Browse files Browse the repository at this point in the history
Co-authored-by: wordpressfan <[email protected]>
  • Loading branch information
wordpressfan and wordpressfan authored Nov 6, 2024
1 parent a9d955a commit 4c31774
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dynamic-lists-delayjs.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions inc/Addon/WebP/Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ public static function get_subscribed_events() {
* @return string
*/
public function convert_to_webp( $html ) {
if ( empty( $html ) ) {
return $html;
}

if ( ! $this->options_data->get( 'cache_webp', 0 ) ) {
return $html;
}
Expand Down
3 changes: 3 additions & 0 deletions inc/Engine/Cache/TaxonomySubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ private function is_not_valid_taxonomy_page() {
}

$current_link = home_url( add_query_arg( [], $wp->request ?? '' ) );
if ( is_paged() ) {
$term_link = trailingslashit( $term_link ) . 'page/' . get_query_var( 'paged' );
}

return untrailingslashit( $term_link ) !== untrailingslashit( $current_link );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@
],
'can_cache' => true,
],
'testValidTaxonomyPageWithPagination' => [
'config' => [
'is_category' => true,
'is_tag' => false,
'is_tax' => false,
'current_term_id' => 1,
'current_term_link' => 'http://example.com/category/test1',
'current_page_url' => 'http://example.com/category/test1/page/2',
'page' => 2,
],
'can_cache' => true,
],
'testEmptyTermId' => [
'config' => [
'is_category' => true,
Expand Down Expand Up @@ -67,5 +79,17 @@
],
'can_cache' => false,
],
'testNotValidTaxonomyPageWithPagination' => [
'config' => [
'is_category' => true,
'is_tag' => false,
'is_tax' => false,
'current_term_id' => 1,
'current_term_link' => 'http://example.com/category/test1',
'current_page_url' => 'http://example.com/category/additional-query/test1/page/2',
'page' => 2,
],
'can_cache' => false,
],
],
];
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public function testShouldReturnExpected( $config, $can_cache ) {
Functions\when( 'get_term_link' )->justReturn( $config['current_term_link'] ?? '' );
Functions\when( 'add_query_arg' )->justReturn( '' );
Functions\when( 'home_url' )->justReturn( $config['current_page_url'] ?? '' );
Functions\when( 'is_paged' )->justReturn( ! empty( $config['page'] ) );
Functions\when( 'get_query_var' )->justReturn( $config['page'] ?? 0 );

$this->assertSame( $can_cache, $this->subscriber->disable_cache_on_not_valid_taxonomy_pages( true ) );
}
Expand Down
4 changes: 2 additions & 2 deletions wp-rocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WP Rocket
* Plugin URI: https://wp-rocket.me
* Description: The best WordPress performance plugin.
* Version: 3.17.2
* Version: 3.17.2.1
* Requires at least: 5.8
* Requires PHP: 7.3
* Code Name: Iego
Expand All @@ -20,7 +20,7 @@
defined( 'ABSPATH' ) || exit;

// Rocket defines.
define( 'WP_ROCKET_VERSION', '3.17.2' );
define( 'WP_ROCKET_VERSION', '3.17.2.1' );
define( 'WP_ROCKET_WP_VERSION', '5.8' );
define( 'WP_ROCKET_WP_VERSION_TESTED', '6.3.1' );
define( 'WP_ROCKET_PHP_VERSION', '7.3' );
Expand Down

0 comments on commit 4c31774

Please sign in to comment.