Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #7029 ALR hashes are added to source when DONOTROCKETOPTIMIZE is set to true #7238

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function add_hashes_when_allowed( $html ) {
* @return string
*/
public function add_hashes( $html ) {
if ( empty( $html ) ) {
if ( empty( $html ) || rocket_get_constant( 'DONOTROCKETOPTIMIZE' ) ) {
return $html;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,20 @@
'html' => file_get_contents( WP_ROCKET_TESTS_FIXTURES_DIR . '/inc/Engine/Optimization/LazyRenderContent/Frontend/Subscriber/html/expected_exclusions.php' ),
]
],
'shouldNotAddHashesWhenDonotoptimize' => [
'config' => [
'donotrocketoptimize' => true,
'row' => [
'url' => 'http://example.org/',
'is_mobile' => 0,
'below_the_fold' => json_encode([]),
'status' => 'completed'
],
'html' => file_get_contents( WP_ROCKET_TESTS_FIXTURES_DIR . '/inc/Engine/Optimization/LazyRenderContent/Frontend/Subscriber/html/original.php' ),
],
'expected' => [
'html' => file_get_contents( WP_ROCKET_TESTS_FIXTURES_DIR . '/inc/Engine/Optimization/LazyRenderContent/Frontend/Subscriber/html/original.php' ),
]
],
]
];
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function tear_down() {
*/
public function testShouldWorkAsExpected( $config, $expected ) {
self::addLrc( $config['row'] );
$this->donotrocketoptimize = $config['donotrocketoptimize'] ?? null;

add_filter( 'rocket_lrc_optimization', '__return_true' );
add_filter( 'rocket_lrc_exclusions', function() use ($config) {
Expand Down
Loading