3.17: Hashes arenot removed from the source when there is no LRC data
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:
- Clear performance hints
- Visit a page that is all is ATF => LRC is [] in DB
- Clear cache
- 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
@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 Yes, this is how it should work.
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_lrcfails (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_datato setbelow_the_foldtonot foundif empty or we updateWP_Rocket\Engine\Optimization\LazyRenderContent\Database\Rows\LazyRenderContent::has_lrcto 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]
Looks good to me
Related TP here => https://wpmediaqa.testrail.io/index.php?/runs/view/894&group_by=cases:section_id&group_order=asc