wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

[Clear Cache Dashboard button] - White screen after clicking clear cache button

Open rosamillan opened this issue 2 years ago • 3 comments

Before submitting an issue please check that you’ve completed the following steps:

  • Made sure you’re on the latest version
  • Used the search feature to ensure that the bug hasn’t been reported before

Describe the bug white screen appears after clicking the "clear cache button"- in the dashboard. The error appears when the header is "Referrer-Policy: no-referrer"

To Reproduce Steps to reproduce the behavior: For the error to appear, the header "Referrer-Policy: no-referrer" must be present

  1. Go to 'wp-admin/options-general.php?page=wprocket#dashboard'
  2. Click on 'Clear and preload cache'
  3. See the error

Expected behavior

  1. Go to 'wp-admin/options-general.php?page=wprocket#dashboard'
  2. Click on 'Clear and preload cache'
  3. The cache is cleared and the dashboard is visible

Screenshots

  1. The Header is "Referrer-Policy: no-referrer" https://jmp.sh/1skSOtrG
  2. Click on 'Clear and preload cache' button: https://jmp.sh/FRoWYyFw
  3. White Screen appears: https://jmp.sh/mr6EL5Sl

Video provided by lucy (awesome debugging job): https://jumpshare.com/j/5QPVMsRAH2ChG0kT12dQ

Additional context This bug was tested in WPR version 3.12.4 and 3.12.5.1 The issue is resolved when you change the header to: Referrer-Policy: strict-origin-when-cross-origin

Alfonso noticed:

  • The White page only appears when the cache is cleared from the dashboard option.

From the toolbar works ok.

  • clear cache from dashboard: https://www.domain.com/wp-admin/admin-post.php?action=purge_cache&type=all&_wpnonce=d4eee5fa26

Works ok: Clear cache from top menu https://www.domain.com/wp-admin/admin-post.php?action=purge_cache&type=all&_wp_http_referer=%2Fwp-admin%2Foptions-general.php%3Fpage%3Dwprocket&_wpnonce=d4eee5fa26

The only difference found it's the top menu link containing the _wp_http_referer and dashboard button no.

Backlog Grooming (for WP Media dev team use only)

  • [ ] Reproduce the problem
  • [ ] Identify the root cause
  • [ ] Scope a solution
  • [ ] Estimate the effort

rosamillan avatar Feb 08 '23 20:02 rosamillan

Scope a solution

A quick fix is to add the referrer to that action. For that we can add the following logic to the renderer:

if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {
				$referer = filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ), FILTER_SANITIZE_URL );
				$referer = '&_wp_http_referer=' . rawurlencode( remove_query_arg( 'fl_builder', $referer ) );
			} else {
				$referer = '';
			}

				$url = admin_url( 'admin-post.php?action=' . $action );

				$url .= $referer;

Estimate the effort

Effort XS

CrochetFeve0251 avatar Feb 09 '23 13:02 CrochetFeve0251

I have a case in which the exact same issue is happening for the "Clear this cache" button in the page list: image

Adding the "&_wp_http_referer=%2Fwp-admin%2F" to the URL works fine for me.

Case related: https://secure.helpscout.net/conversation/2461303037/465232/ WP Rocket version: 3.15.7

sandyfigueroa avatar Jan 17 '24 21:01 sandyfigueroa

https://secure.helpscout.net/conversation/2523194404/477364 https://beddenspeciaalzaakhendriksen.nl

It looks like I have a case related to this issue but in reverse. In the initial case for this issue, cache clear attempts result in white page due to the "Referrer-Policy: no-referrer" header. In that case, the clear cache link did not include _wp_http_referer=%2Fwp-admin%2Foptions-general.php%3Fpage%3Dwprocket.

However, in my ticket above, the "Referrer-Policy: strict-origin-when-cross-origin" header is set, and the link also does contain the _wp_http_referer=%2Fwp-admin%2Fplugins.php param, but I get a white screen when clearing cache.

If I remove the _wp_http_referer param from the clear cache link, then clearing the cache does work: https://secure.helpscout.net/conversation/2523194404/477364/#thread-7575853068

joejoe04 avatar Feb 27 '24 17:02 joejoe04

Related case: White screen when Clear Cache is clicked from Single Edit Post Sidebar:

https://secure.helpscout.net/conversation/2736897712/518288?folderId=8127831

jekayode avatar Oct 21 '24 15:10 jekayode