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

ALR hashes are added to source when DONOTROCKETOPTIMIZE is set to true

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

Describe the bug When DONOTROCKETOPTIMIZE is set to true , hashes are added to the page

To Reproduce Steps to reproduce the behavior:

  1. add define('DONOTROCKETOPTIMIZE', true);
  2. Visit a page in incognito
  3. 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

Mai-Saad avatar Oct 11 '24 09:10 Mai-Saad

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

Khadreal avatar Jan 22 '25 17:01 Khadreal

Created a PR here

Khadreal avatar Jan 23 '25 05:01 Khadreal

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

hanna-meda avatar Jan 28 '25 06:01 hanna-meda

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]

jeawhanlee avatar Jul 16 '25 21:07 jeawhanlee

LGTM

Miraeld avatar Jul 17 '25 01:07 Miraeld

Related Test Plan: https://wpmediaqa.testrail.io/index.php?/runs/view/1044.

hanna-meda avatar Jul 25 '25 10:07 hanna-meda

Related TP: https://wpmediaqa.testrail.io/index.php?/runs/view/1170

hanna-meda avatar Dec 23 '25 12:12 hanna-meda