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

Fix Multisite Cache Deletion Issue with lazyload background images feature #7226

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inc/Engine/Common/ExtractCSS/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function register(): void {
*
* @param string $root Background CSS cache folder.
*/
$root = apply_filters( 'rocket_lazyload_css_cache_root', 'background-css' );
$root = apply_filters( 'rocket_lazyload_css_cache_root', 'background-css/' . get_current_blog_id() );
$this->getContainer()->add( 'lazyload_css_cache', FilesystemCache::class )
->addArgument( $root );
$this->getContainer()->addShared( 'common_extractcss_subscriber', Subscriber::class );
Expand Down
3 changes: 0 additions & 3 deletions inc/Engine/Media/Lazyload/CSS/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ public function provides( string $id ): bool {
* @return void
*/
public function register(): void {
$this->getContainer()->add( 'lazyload_css_cache', FilesystemCache::class )
->addArgument( apply_filters( 'rocket_lazyload_css_cache_root', 'background-css/' . get_current_blog_id() ) );

$cache = $this->getContainer()->get( 'lazyload_css_cache' );

$this->getContainer()->add( 'lazyload_css_context', LazyloadCSSContext::class )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
WP Rocket</strong>
cannot configure itself due to missing writing permissions.<br>
Affected file/folder:<code>
vfs://public/wp-content/cache/background-css/</code>
vfs://public/wp-content/cache/background-css/1/</code>
<br>
Troubleshoot:<a href="https://docs.wp-rocket.me/article/626-how-to-make-system-files-htaccess-wp-config-writeable/?utm_source=wp_plugin&utm_medium=wp_rocket" target="_blank">
How to make system files writeable</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<title>
HTML 5 Boilerplate</title>
<!-- external CSS background images here min and non-min file -->
<link rel="stylesheet" href="http://example.org/wp-content/cache/background-css/example.org/wp-content/rocket-test-data/styles/lazyload_css_background_images.css?test=1&wpr_t=17895120">
<link rel="stylesheet" href="http://example.org/wp-content/cache/background-css/1/example.org/wp-content/rocket-test-data/styles/lazyload_css_background_images.css?test=1&wpr_t=17895120">
<link rel="stylesheet" href="/wp-content/rocket-test-data/styles/excluded.css">
<link rel="stylesheet" href="http://example.org/wp-content/cache/background-css/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/lazyload_css_background_images.min.css?wpr_t=17895120">
<link rel="stylesheet" href="http://example.org/wp-content/cache/background-css/1/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/lazyload_css_background_images.min.css?wpr_t=17895120">
<link rel="stylesheet" href="https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/no_background.css">
<!-- CSS loaded by js, probably won't be processed -->
<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>HTML 5 Boilerplate</title>
<!-- external CSS background images here min and non-min file -->
<link rel="stylesheet" href="http://example.org/wp-content/cache/background-css/example.org/wp-content/rocket-test-data/styles/lazyload_css_background_images.css?test=1&wpr_t=17895120">
<link rel="stylesheet" href="http://example.org/wp-content/cache/background-css/example.org/wp-content/rocket-test-data/styles/excluded.css?wpr_t=17895120">
<link rel="stylesheet" href="http://example.org/wp-content/cache/background-css/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/lazyload_css_background_images.min.css?wpr_t=17895120">
<link rel="stylesheet" href="http://example.org/wp-content/cache/background-css/1/example.org/wp-content/rocket-test-data/styles/lazyload_css_background_images.css?test=1&wpr_t=17895120">
<link rel="stylesheet" href="http://example.org/wp-content/cache/background-css/1/example.org/wp-content/rocket-test-data/styles/excluded.css?wpr_t=17895120">
<link rel="stylesheet" href="http://example.org/wp-content/cache/background-css/1/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/lazyload_css_background_images.min.css?wpr_t=17895120">
<link rel="stylesheet" href="https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/no_background.css">

<!-- CSS loaded by js, probably won't be processed -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,26 @@
'expected' => [
'output' => $html_filtered,
'files' => [
'/wp-content/cache/background-css/example.org/wp-content/rocket-test-data/styles/lazyload_css_background_images.css' => [
'/wp-content/cache/background-css/1/example.org/wp-content/rocket-test-data/styles/lazyload_css_background_images.css' => [
'exists' => true,
'content' => file_get_contents(__DIR__ . '/CSS/lazyloaded.css')
],
'/wp-content/cache/background-css/example.org/wp-content/rocket-test-data/styles/lazyload_css_background_images.css.json' => [
'/wp-content/cache/background-css/1/example.org/wp-content/rocket-test-data/styles/lazyload_css_background_images.css.json' => [
'exists' => true,
'content' => file_get_contents(__DIR__ . '/CSS/lazyload.css.json')
],
'/wp-content/cache/background-css/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/lazyload_css_background_images.min.css' => [
'/wp-content/cache/background-css/1/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/lazyload_css_background_images.min.css' => [
'exists' => true,
'content' => file_get_contents(__DIR__ . '/CSS/external_lazyloaded.css')
],
'/wp-content/cache/background-css/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/lazyload_css_background_images.min.css.json' => [
'/wp-content/cache/background-css/1/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/lazyload_css_background_images.min.css.json' => [
'exists' => true,
'content' => file_get_contents(__DIR__ . '/CSS/external.css.json')
],
'/wp-content/cache/background-css/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/no_background.css' => [
'/wp-content/cache/background-css/1/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/no_background.css' => [
'exists' => false,
],
'/wp-content/cache/background-css/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/no_background.css.json' => [
'/wp-content/cache/background-css/1/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/no_background.css.json' => [
'exists' => false,
],
]
Expand Down Expand Up @@ -110,26 +110,26 @@
'expected' => [
'output' => $html_excluded,
'files' => [
'/wp-content/cache/background-css/example.org/wp-content/rocket-test-data/styles/lazyload_css_background_images.css' => [
'/wp-content/cache/background-css/1/example.org/wp-content/rocket-test-data/styles/lazyload_css_background_images.css' => [
'exists' => true,
'content' => file_get_contents(__DIR__ . '/CSS/lazyloaded.css')
],
'/wp-content/cache/background-css/example.org/wp-content/rocket-test-data/styles/lazyload_css_background_images.css.json' => [
'/wp-content/cache/background-css/1/example.org/wp-content/rocket-test-data/styles/lazyload_css_background_images.css.json' => [
'exists' => true,
'content' => file_get_contents(__DIR__ . '/CSS/lazyload.css.json')
],
'/wp-content/cache/background-css/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/lazyload_css_background_images.min.css' => [
'/wp-content/cache/background-css/1/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/lazyload_css_background_images.min.css' => [
'exists' => true,
'content' => file_get_contents(__DIR__ . '/CSS/external_lazyloaded.css')
],
'/wp-content/cache/background-css/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/lazyload_css_background_images.min.css.json' => [
'/wp-content/cache/background-css/1/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/lazyload_css_background_images.min.css.json' => [
'exists' => true,
'content' => file_get_contents(__DIR__ . '/CSS/external.css.json')
],
'/wp-content/cache/background-css/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/no_background.css' => [
'/wp-content/cache/background-css/1/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/no_background.css' => [
'exists' => false,
],
'/wp-content/cache/background-css/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/no_background.css.json' => [
'/wp-content/cache/background-css/1/new.rocketlabsqa.ovh/wp-content/rocket-test-data/styles/no_background.css.json' => [
'exists' => false,
],
]
Expand Down
Loading