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

3.17: Hashes arenot removed from the source when there is no LRC data

Open Mai-Saad opened this issue 1 year ago • 4 comments

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

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

Describe the bug When accessing a page that is totally above the fold and having lrc as [] in DB , hashes aren't removed from source

To Reproduce Steps to reproduce the behavior:

  1. Clear performance hints
  2. Visit a page that is all is ATF => LRC is [] in DB
  3. Clear cache
  4. Visit the page again => hashes are there

Expected behavior Hashes should be removed when visiting uncached page that have [] LRC in DB

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

  • slack https://wp-media.slack.com/archives/CUT7FLHF1/p1724850889231899
  • If screen size is unacceptable, the script will bailout and hashes will always be there in the source => expected

Acceptance Criteria (for WP Media team use only) Clear instructions for developers, to be added before the grooming

Mai-Saad avatar Aug 28 '24 14:08 Mai-Saad

@piotrbak I think the case where the LRC row contains a status different than "completed" should be added here too. I think currently, if the row is failed, it will have the same issue.

MathieuLamiot avatar Aug 28 '24 14:08 MathieuLamiot

@MathieuLamiot Yes, this is how it should work.

piotrbak avatar Aug 28 '24 21:08 piotrbak

Reproduce the issue ✅

I was able to reproduce the issue with the same steps in this issue.

Identify the root cause ✅

There are 2 reasons for this:

  • The first is here, so for a situation when [] is saved in DB, it would pass the has_lrc check but will not pass here and return back the same html without removing hashes
  • The second is here, even when has_lrc fails (status is not complete or below_the_fold is empty or below_the_fold is 'not found' which we don't do at the moment) we will return back the same html buffer without removing the hashes.

Scope a solution ✅

  • We either update WP_Rocket\Engine\Optimization\LazyRenderContent\AJAX\Controller::add_data to set below_the_fold to not found if empty or we update WP_Rocket\Engine\Optimization\LazyRenderContent\Database\Rows\LazyRenderContent::has_lrc to replace 'not found' with '[]' - Then we remove hashes every time we do a early return here, here & here

  • Update tests for this.

Estimate the effort ✅

[S]

jeawhanlee avatar Aug 29 '24 10:08 jeawhanlee

Looks good to me

Miraeld avatar Aug 29 '24 12:08 Miraeld

Related TP here => https://wpmediaqa.testrail.io/index.php?/runs/view/894&group_by=cases:section_id&group_order=asc

hanna-meda avatar Sep 04 '24 13:09 hanna-meda