ALR hashes are added to source when DONOTROCKETOPTIMIZE is set to true
Describe the bug When DONOTROCKETOPTIMIZE is set to true , hashes are added to the page
To Reproduce Steps to reproduce the behavior:
- add define('DONOTROCKETOPTIMIZE', true);
- Visit a page in incognito
- See the hashes are added
Expected behavior
- Hashes aren't added if DONOTROCKETOPTIMIZE is set to true
- No warmup for lrc/lcp
- beacon still not injected
AC
- Turn off ALR hashes when DONOTROCKETOPTIMIZE is set.
Additional context Add any other context about the problem here.
- preventing the beacon injection was implemented here https://github.com/wp-media/wp-rocket/pull/7022
Scope a solution
To solve the issue, we need to add DONOTROCKETOPTIMIZE logic to `add_hashes. In this file we can modify this logic to be this
if ( empty( $html ) || rocket_get_constant( 'DONOTROCKETOPTIMIZE' ) ) {
//return early
}
Effort estimation:
XS
Created a PR here
For testing:
- execute TC from TP: https://wpmediaqa.testrail.io/index.php?/runs/view/956 + confirm that no hashes are added in that case
- run LRC e2e on PR
Scope a solution ✅
PREVENT HASHES
In WP_Rocket\Engine\Optimization\LazyRenderContent\Context\Context::is_allowed
- Add condition to check rocket_get_constant( 'DONOTROCKETOPTIMIZE' ) value
- Return false early if true.
PREVENT WARMUP
In WP_Rocket\Engine\Common\PerformanceHints\WarmUp\Controller::is_allowed
- Add rocket_get_constant( 'DONOTROCKETOPTIMIZE' ) to the return.
Add tests/update tests
Estimate effort ✅
[S]
LGTM
Related Test Plan: https://wpmediaqa.testrail.io/index.php?/runs/view/1044.
Related TP: https://wpmediaqa.testrail.io/index.php?/runs/view/1170