From fe1981dfcc547acb68ad9a8e9271326ae3e7d5e0 Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Thu, 30 Jan 2025 13:39:18 +0100 Subject: [PATCH] Release 3.18.1.1 (#7262) Co-authored-by: WordPress Fan <146129302+wordpressfan@users.noreply.github.com> --- inc/Engine/Common/Cache/FilesystemCache.php | 4 +++ .../Cache/FilesystemCache/isAccessible.php | 36 ++++++++++++++----- wp-rocket.php | 4 +-- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/inc/Engine/Common/Cache/FilesystemCache.php b/inc/Engine/Common/Cache/FilesystemCache.php index d3c0d43478..61187e0216 100644 --- a/inc/Engine/Common/Cache/FilesystemCache.php +++ b/inc/Engine/Common/Cache/FilesystemCache.php @@ -243,6 +243,10 @@ public function generate_path( string $url ): string { * @return bool */ public function is_accessible(): bool { + $base_path = $this->get_base_path(); + if ( ! $this->filesystem->exists( $base_path ) ) { + rocket_mkdir_p( $base_path, $this->filesystem ); + } $root_path = $this->get_root_path(); if ( ! $this->filesystem->exists( $root_path ) ) { rocket_mkdir_p( $root_path, $this->filesystem ); diff --git a/tests/Unit/inc/Engine/Common/Cache/FilesystemCache/isAccessible.php b/tests/Unit/inc/Engine/Common/Cache/FilesystemCache/isAccessible.php index 43f0c0c2c7..f762df0017 100644 --- a/tests/Unit/inc/Engine/Common/Cache/FilesystemCache/isAccessible.php +++ b/tests/Unit/inc/Engine/Common/Cache/FilesystemCache/isAccessible.php @@ -11,7 +11,7 @@ /** * Test class covering \WP_Rocket\Engine\Common\Cache\FilesystemCache::is_accessible */ -class TestIsAccessible extends TestCase { +class Test_IsAccessible extends TestCase { protected $root_folder; protected $filesystem; protected $filesystemcache; @@ -27,17 +27,35 @@ public function set_up() { /** * @dataProvider configTestData + * @throws \Exception */ public function testShouldReturnAsExpected( $config, $expected ) { - Functions\when('rocket_get_constant')->justReturn($config['root']); - Functions\when('get_current_blog_id')->justReturn( 1 ); + Functions\when('rocket_get_constant')->justReturn($config['root']); + Functions\when('get_current_blog_id')->justReturn( 1 ); - $this->filesystem->shouldReceive('exists')->with($expected['path'])->andReturn($config['exists']); - if( ! $config['exists']) { - Functions\expect('rocket_mkdir_p')->with($expected['path'], $this->filesystem); - } - $this->filesystem->shouldReceive('is_writable')->with($expected['path'])->andReturn($config['is_writable']); + $base_path = $config['root'] . $this->root_folder; + $root_path = $expected['path']; + + + $this->filesystem->shouldReceive('exists') + ->with($base_path) + ->andReturn($config['exists']); + + if( ! $config['exists']) { + Functions\expect('rocket_mkdir_p')->with($base_path, $this->filesystem); + } + + $this->filesystem->shouldReceive('exists') + ->with($root_path) + ->andReturn($config['exists']); + + if (!$config['exists']) { + Functions\expect('rocket_mkdir_p') + ->with($root_path, $this->filesystem); + } + + $this->filesystem->shouldReceive('is_writable')->with($root_path)->andReturn($config['is_writable']); - $this->assertSame($expected['output'], $this->filesystemcache->is_accessible()); + $this->assertSame($expected['output'], $this->filesystemcache->is_accessible()); } } diff --git a/wp-rocket.php b/wp-rocket.php index 9ce7601865..9fef332817 100755 --- a/wp-rocket.php +++ b/wp-rocket.php @@ -3,7 +3,7 @@ * Plugin Name: WP Rocket * Plugin URI: https://wp-rocket.me * Description: The best WordPress performance plugin. - * Version: 3.18.1 + * Version: 3.18.1.1 * Requires at least: 5.8 * Requires PHP: 7.3 * Code Name: Iego @@ -20,7 +20,7 @@ defined( 'ABSPATH' ) || exit; // Rocket defines. -define( 'WP_ROCKET_VERSION', '3.18.1' ); +define( 'WP_ROCKET_VERSION', '3.18.1.1' ); define( 'WP_ROCKET_WP_VERSION', '5.8' ); define( 'WP_ROCKET_WP_VERSION_TESTED', '6.3.1' ); define( 'WP_ROCKET_PHP_VERSION', '7.3' );